G
G
Gera112020-03-10 11:57:34
Nginx
Gera11, 2020-03-10 11:57:34

How to set up websocket over ssl on nginx?

I 'm using nginx + docker + certificate from Lets'encrypt
The engine of my site uses websocket, and I managed to install ssl on the site itself, but I can't install it on websocket. Tried different tips from the internet but didn't work. Please tell me how to correctly configure the websocket on ssl in .conf? to be in wss://
here is my .conf:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name  localhost;

    ssl_certificate /etc/letsencrypt/live/trade.reyna2.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/trade.reyna2.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/trade.reyna2.com/chain.pem;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

server {
    listen 80;
    listen [::]:80;

    server_name *.trade.reyna2.com trade.reyna2.com;

    location / {
        return 301 https://trade.reyna2.com$request_uri;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wexter, 2020-03-10
@Wexter

https://www.nginx.com/blog/websocket-nginx/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question