D
D
Dimash Kenzhegaliev2021-07-06 13:27:18
Nginx
Dimash Kenzhegaliev, 2021-07-06 13:27:18

How to configure nginx under websocket from ws to wss?


I now have the following settings in the /etc/nginx/sites-available/websocket file

server {
        listen 443 ssl;

        server_name socket.example.com;

        error_page 404 /;

        location / {
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_pass http://localhost:1000;
  }

        ssl_certificate /etc/letsencrypt/live/socket.example.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/socket.example.com/privkey.pem; # managed by Certbot
}


and until i put letsencrypt ssl certificate everything worked fine on port 2000
but now i sincerely don't understand how to broadcast localhost:1000 to wss://socket.example.com
i'm new to nginx and i already understand how it works in principle, but how to do it without a clue, I already googled a lot of things I tried a lot but it still doesn’t work, maybe some other ssl certificate is needed, I don’t know please help me, I’ve been sitting on this all day

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Gorgul, 2021-07-19
@xXxSPYxXx

It won't work since nginx is http/s, not ws/wss.
Configure your application itself to work on wss or the client must understand that it works via https on wss.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question