I am using my first attempt to use django + gunicorn + nginx.
curl -XGET http://127.0.0.0.1:8000 working for me ( curl -XGET http://127.0.0.0.1:8000 works fine if I start the development server).- My nginx works for static content (for example, I can get
http://example.com/static/my_pic.png in my browser). - I am not getting any wsgi content from my site and I have not been able to find a good troubleshooting guide (this just works for everyone!). I start shooting with the help of a supervisor who reports that it really works:
(in shell :)
supervisorctl status my_app my_app RUNNING pid 1002, uptime 0:29:51
Here's the script template I used to run it:
#!/bin/bash
Here's the configured nginx configuration file:
upstream my_server { server unix:/webapps/www/run/gunicorn.sock fail_timeout=10s; } server { listen 80; server_name www.example.com; return 301 $scheme://example.com$request_uri; } server { listen 80; server_name example.com; client_max_body_size 4G; access_log /webapps/www/logs/nginx-access.log; error_log /webapps/www/logs/nginx-error.log; location /favicon.ico { access_log off; log_not_found off; } location /static/ { autoindex on; alias /webapps/www/my_project/my_app/static/; } location /media/ { autoindex on; alias /webapps/www/my_project/my_app/media/; } location / { proxy_pass http://my_server; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://example.com; break; } } location /robots.txt { alias /webapps/www/my_project/my_app/static/robots.txt ; }
So: gunicorn is running, nginx works ... what tests (and how?) Should I run to determine if gunicorn wsgi is working correctly (and if nginx proxies the specified material correctly)?
Edit: I narrowed the problem down to communication between the gun and nginx through the unix socket. If I change the $ SOCKFILE bound to 0.0.0.0:80 and stop nginx, the application pages will be sent from my site. The bad news is that the lines of the socket file are the same between the two conf files, so I don't know why they are not reporting. I suppose this means that nginx is incorrectly retrieving and passing data through?
source share