I followed this tutorial to deploy my Django project on DigitalOcean. I've installed Nginx and Supervisor and all worked until I set DEBUG option in the settings.py to False
I tried to configure nginx.conf and settings.py million times. Changing root to alias wouldn't help.
Nginx configuration file:
upstream app_server {
server unix:/home/db1/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
# add here the ip address of your server
# or a domain pointing to that ip (like example.com or www.example.com)
server_name ...;
keepalive_timeout 5;
client_max_body_size 4G;
access_log /home/db1/logs/nginx-access.log;
error_log /home/db1/logs/nginx-error.log;
location /static/ {
root /home/db1/site1/static;
}
# checks for static file, if not found proxy to app
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
Settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')