How to change wss://domain.com:1234 to no port access?

1. The console input code can connect successfully, but Mini Program cannot add a port, so it should be changed to a portless connection

.
ws = new WebSocket("wss://:1234");

ws.onopen = function() {
    alert("");
    ws.send("tom");
    alert(":tom");
};
ws.onmessage = function(e) {
    alert(":" + e.data);
};

2. The server is Nginx
3. The reverse proxy setting on the pagoda panel does not work. I do not know if the setting is wrong

.

clipboard.png

4

clipboard.png

upstream websocket { 
    server ip:;  //
}
server {
        location /wss {
             access_log /usr/share/nginx/logs/https-websocket.log;
             proxy_pass http://websocket/; -sharp 
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
             rewrite /wss/(.*) /$1 break;
             proxy_redirect off;
        } 
}

5. There is one thing I don"t know about my first contact. I suspended the website. Why ws = new WebSocket ("wss:// domain name: 1234"); can still connect successfully


learn about ssl certificate


if you need a port, https does not add a port, and the default port is 443 answer. You can try


if you want to add no port, you need to set the listening port to 443 . By default: ws port is 80 , and wss port is 443

< hr class= "answer >

. Reverse proxy to port 1234 via nginx

Menu