How to configure https and wss for nginx, nginxhttpswss
How to configure https and wss for nginx
server { listen 443 ssl; server_name localhost; ssl on; root html; index index.html index.htm; ssl_certificate ******.pem; ssl_certificate_key *******.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location /{ proxy_pass https://localhost:3001; } location /ws { proxy_pass https://localhost:8181; proxy_read_timeout 60s; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'Upgrade'; } }
The handshake of the WebSocket protocol is compatible with HTTP. It uses the HTTP Upgrade protocol header to Upgrade the connection from the HTTP connection to the WebSocket connection. This feature makes it easy for WebSocket applications to apply to existing infrastructure.
You can use https // + domain name to access and use wss: // + domain name +/ws to access