I'm trying to deploy a readthedocs instance on my own server. The recommended way to deploy is using Gunicorn + nginx with postgres. Because there's basically no documentation on how to do this (except from their fabfiles which of course, only works on their server), I've been trying to setup my own server, manually.
Here's my nginx.conf
:
server {
listen 80 default;
server_name mysite.com;
access_log /var/log/nginx/mysite.access.log;
error_log /var/log/nginx/mysite.error.log;
location /favicon.ico {
root /home/mysite/Code/checkout/readthedocs.org/media/images;
break;
}
location robots.txt {
root /home/mysite/Code/checkout/readthedocs.org/media;
break;
}
location /static/ {
alias /home/mysite/Code/checkout/readthedocs.org/media/;
expires 30d;
break;
}
location /media/ {
alias /home/mysite/Code/checkout/readthedocs.org/media/;
expires 30d;
break;
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://127.0.0.1:8888;
}
}
The settings.py
for django configuration can be found here. The only thing I changed on settings.py
is I add gunicorn
on INSTALLED_APPS
so I can run gunicorn with it.
The command I use to run the gunicorn server is:
./manage.py run_gunicorn -b 127.0.0.1:8888
Then if I try to access 127.0.0.1
from a local browser, it would work, but always show a 404 page, no matter what URL I entered. Running ./manage.py runserver
will run everything correctly.
Now I am not a sysadmin, and have basically 0 experience with django, gunicorn, or nginx before. I've been googling and playing around the configuration for weeks, with 0 result. My question is:
- How do I know which django's route called by gunicorn? Can I debug this? All log files that I can find didn't show this.
- Do you see anything wrong with my configuration file? If so, could you please tell me what's wrong?
Thank you very much.