简体   繁体   中英

Django nginx 502 bad gateway

I am learing nginx for django, i am running the server in locally with docker.

this is my django_nginix.conf file :

server {
listen 80;
listen [::]:80 default_server;
server_name musicaldd.com;

client_max_body_size 90M;

location /media/ {
    root /home/pyking/cpd/musicaldd_back/storage/;
}

location /static/ {
    root /home/pyking/cpd/musicaldd_back/storage/;
}

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_buffering off;
    proxy_pass http://djangoapp:8000/;
}

}

When I run the server creating docker images and hit the URLs, it returns me 502-bed getaway timeout | nginix 502-bed getaway timeout | nginix Can anyone tell me why this errors occuse, how can I fix this error

It may stupid question but this is very serious to me, coz, i am new on Nginx, it will really much be appreciated if you help me to fix this

If you are using uwsgi add this to your nginx.conf file based on your uwsgi params file location.

include   /etc/nginx/uwsgi_params;
uwsgi_pass  unix://tmp/uwsgi.sock;
uwsgi_param SCRIPT_NAME /;

If you are not i suggest use that. there is another option called gunicorn but uwsgi has better performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM