2016-11-15 9 views
0

Amazon EC2で私のDjangoプロジェクトをホスティングする際に問題が発生しています。 ブラウザ(JavaScriptコンソールから抜粋)で私のページをロードしようとしたときにサイトをホストすることGunicornとnginxのを使用して、私は次のエラーを取得する:HTTP 504ゲートウェイDjango(Nginx + Gunicorn)で静的ファイルを提供するときのタイムアウト

Failed to load resource: the server responded with a status of 504 (Gateway Time-out): https://example.com/favicon.ico 

私はnginxのは、いくつかの問題私の静的ファイルを見つけることがあると信じて、なぜ私は確信していません。何も表示されません/var/log/nginx/error.log

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と猫:ここに私のnginxの設定ファイルです。

HTTPコード504では、通常、長いリクエストがハングアップして最終的にタイムアウトする問題がありますが、サイトをロードしようとしているだけなので、プロジェクトにどのように適用されるのか分かりません。

この問題をデバッグする方法がわからないので、助けてください!

答えて

0

これはあなたを助けることがあります。次のように私が何をしたか

私は/etc/nginx/site-enabled/defaultファイルを編集しているされています

server { 
     #nginx server configuration 
     listen 80 default_server; 
#  listen [::] default_server ipv6only=on; 
     listen [::]:80 default_server ipv6only=on; 

     root /usr/share/nginx/html; 
     index index.html index.htm; 

     # Make site accessible from http://localhost/ 
#  server_name localhost; 
     # provide whole path of static files you got after running `python manage.py collectstatics` 
     location /static{ 
       alias /home/ubuntu/folder1/folder2/webpage/static; 
     } 

     location/{ 
       # First attempt to serve request as file, then 
       # as directory, then fall back to displaying a 404. 
       proxy_pass http://0.0.0.0:8134;#Provide your django server's link 
       # Uncomment to enable naxsi on this location 
       # include /etc/nginx/naxsi.rules 
     } 
} 

を: - あなたはpython manage.py collectstaticsを行っていることを確認してください。 nginx.confファイルで何も変更しないでください

関連する問題