I've been having problem hosting my Django project on Amazon EC2. Using Gunicorn and Nginx to host the site, I get the following error when trying to load my page in the browser (excerpt from the Javascript console):
Failed to load resource: the server responded with a status of 504 (Gateway Time-out): https://example.com/favicon.ico
I believe Nginx has some problems finding my static files, but I'm not sure why. Here's my Nginx config:
server {
listen 443 default;
client_max_body_size 100M;
server_name www.example.com;
keepalive_timeout 5;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
# the domain name it will serve for
charset utf-8;
# path for static files
root /opt/app/staticfiles;
location /static {
root /opt/app/staticfiles;
}
location / {
# checks for static file, if not found proxy to app
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;
}
}
/var/log/nginx/access.log and cat /var/log/nginx/error.log don't show anything.
For HTTP code 504 it is usually a problem that a long request is hanging and eventually times out, but I'm not sure how it applies to my project, since I'm only trying to load the site.
Not sure how to debug this issue, so any help is appreciated!