I am running a Django site on DigitalOcean using 1ClickInstallation image. Every thing worked fine but I got issue for 504 Gateway Timeout Error. I've tried multiple settings on blogs but not working. Following are my settings:
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/django/django_project;
index index.html index.htm;
client_max_body_size 4G;
server_name www.mydomain.com;
keepalive_timeout 5;
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2|woff|ttf)$ {
expires 365d;
}
# Your Django project's media files - amend as required
location /media {
alias /home/django/django_project/media/;
}
# your Django project's static files - amend as required
location static/static-only {
alias /home/django/django_project/static-only/;
}
# Django static images
location /static/django_project/images {
alias /home/django/django_project/static-only/django_project/images/;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin;
}
location / {
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;
}
}
I followed docs at following link http://nginx.org/en/docs/http/ngx_http_limit_req_module.html
Following is the result of "wget 127.0.0.1:9000"
but couldn't make sense that where exactly to add directives. Kindly advise.
If you are using uwsgi with django, then you might add uwsgi_read_timeout directive to nginx's config file at location place
location / {
uwsgi_read_timeout 120;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With