How to configure https and wss for nginx, nginxhttpswss

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.