Amazon EC2 で Django プロジェクトをホストする際に問題が発生しています。Gunicorn と Nginx を使用してサイトをホストしている場合、ブラウザーでページを読み込もうとすると、次のエラーが表示されます (Javascript コンソールからの抜粋)。
Failed to load resource: the server responded with a status of 504 (Gateway Time-out): https://example.com/favicon.ico
Nginx には静的ファイルの検索に問題があると思いますが、その理由はわかりません。これが私のNginx構成です:
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 と cat /var/log/nginx/error.log には何も表示されません。
HTTP コード 504 の場合、通常、長いリクエストがハングして最終的にタイムアウトになることが問題ですが、サイトを読み込もうとしているだけなので、プロジェクトにどのように適用されるかわかりません。
この問題をデバッグする方法がわからないので、助けていただければ幸いです。