1

So I was trying to follow this tutorial: http://jronnholm.sysio.se/setup-nginx-and-uwsgi-with-python3-on-ubuntu-14-04/

I'm using vagrant and virtualbox with port forwarding from 8080 to 80

root@vagrant:/etc/nginx/sites-available# cat pythonapp
server {
    server_name pythonapp;
    error_log  /var/log/nginx/pythonapp.error.log;
    access_log         /var/log/nginx/pythonapp.access.log;
    root /vagrant/site/python/pythonapp;
    location / {
        uwsgi_pass unix:/var/run/uwsgi/app/pythonapp/socket;
        include uwsgi_params;
    }
}


root@vagrant:/etc/nginx/sites-available# cat /etc/uwsgi/apps-available/pythonapp.ini
[uwsgi]
uid=www-data
gid=www-data
# socket line should match uwsgi_pass line in your nginx config
socket = /var/run/uwsgi/app/pythonapp/socket
chown-socket = www-data
chdir = /vagrant/site/python/pythonapp
file = webpage.py
root@vagrant:/etc/nginx/sites-available#

root@vagrant:/vagrant/site/python# ls -l
total 2
drwxrwxrwx 1 vagrant vagrant   0 Feb  7 22:59 pythonapp
-rwxrwxrwx 1 vagrant vagrant 155 Feb  7 19:59 pythonapp.ini
-rwxrwxrwx 1 vagrant vagrant 160 Feb  2 08:27 wsgi.py
-rwxrwxrwx 1 vagrant vagrant 378 Feb  2 08:27 wsgi.pyc
root@vagrant:/vagrant/site/python#

but then when I go to http://localhost:8080 it ends up returning

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

content of webpage.py

root@vagrant:/vagrant/site/python/pythonapp# cat webpage.py
from bottle import route, run, template, default_app

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

if __name__ == "__main__":
    run(host='localhost', port=8080)
else:
    application = default_app()

and when I go to http://localhost:8080/hello/name it ends up returning 404 not found even though the tutorial suggests that going to /hello/name should load the webpage.py...

what am I doing wrong?

4
  • It might also be helpful to see your URL configuration of your python app - it's possible that the paths are not set up correctly on that end and that's why you're getting a 404. Commented Feb 7, 2017 at 23:35
  • the rest are identical with the tutorial.....added content of webpage.py Commented Feb 7, 2017 at 23:40
  • I suggest you hardcode to @route('/hello/abc') to see if it actually works. Also you sure your uwsgi is running? Commented Feb 7, 2017 at 23:57
  • 1
    You set the server_name this will only serve request with matching hostname. If it does not match (like localhost) the default server will take over serving the default page. Commented Feb 8, 2017 at 0:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.