Bearle / django-private-chat

(Deprecated - Please check out https://github.com/Bearle/django_private_chat2) Django one-to-one Websocket-based Asyncio-handled chat, developed by Bearle team
ISC License
424 stars 132 forks source link

Trying to serve django site with wss and https #35

Closed mariush2 closed 5 years ago

mariush2 commented 5 years ago

Description

Hi, I am having some trouble serving my site with wss. The page is working normally on https with a let's encrypt certificate, but I get a WebSocket connection to 'wss://206.189.14.41:5002/yt44d1zlwonllj0i8ezj0iku8awwep6o/marius' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT when I go into my chat page.

Here is my config for django-private-chat:

# Server settings for private chat
CHAT_WS_SERVER_HOST = '206.189.14.41'
CHAT_WS_SERVER_PORT = 5002
CHAT_WS_SERVER_PROTOCOL = 'wss'

I think the issue is in my nginx config, but I can't figure out what's wrong with my config.

Here is my nginx config:

server {
    server_name shareboi.com www.shareboi.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
    autoindex on;
        alias /root/shareboi/static/;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/run/uwsgi/shareboi.sock;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/shareboi.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/shareboi.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.shareboi.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = shareboi.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name shareboi.com www.shareboi.com;
    return 404; # managed by Certbot

}
server {
    listen 5002;

    location / {
    proxy_pass https://shareboi.com;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}

Anyone have a suggestion to resolve this?

mariush2 commented 5 years ago

Managed to sort out what was wrong.

ledzgio commented 4 years ago

Managed to sort out what was wrong.

What was wrong? it would help if you explain how you fixed it.