I have configure Django Channels successfully in my local it is working fine in my local, also I'm able to chat one to one using websocket. when I try to deploy it to server and try to connect with websocket it shows status 502 Bad Gateway. I try so many thing but i'm stucked now anyone of you guys can help me to overcome this problem thanx in advance.
This is the nginx configuration of my project..
upstream websocket {
server www.domain_name.com:8000;
#SERVER endpoint that handle ws:// connections
}
server {
server_name www.domain_name.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/django/app;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 128;
}
location /v1 {
include proxy_params;
client_max_body_size 100M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_pass http://websocket;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.domain_name.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.domain_name.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.domain_name.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name www.domain_name.com;
return 404; # managed by Certbot
}
The error I got in nginx errors.log in below screenshot. enter image description here