Nginx configuration supports HTTPS and WSS (websocket) protocol

Source: Internet
Author: User

Server {Listen80; Listen443SSL HTTP2; server_name lyz810.com; Root/website/lyz810-main; Ssl_certificate Certificate/lyz810.com.CRT; Ssl_certificate_key Certificate/lyz810.com.Key; Location/websocket/{internal; if($http _sec_websocket_protocol= "" ) {                        return400; } Proxy_pass http://127.0.0.1: $arg _port;Proxy_http_version 1.1; Proxy_set_header X-client-ip$remote _addr; Proxy_set_header Upgrade$http _upgrade; Proxy_set_header Connection"Upgrade";        Proxy_read_timeout 300s; } Location/Chatroom {rewrite. */websocket/?port=8100; } Location/Chatrobot {rewrite. */WEBSOCKET/?PORT=8101; }}

Server Internal 2 websocket services, respectively, monitoring 8100, 8101 Port Nginx based on access to different location, select Agent to the WS service Provider

/websocket/is an internal location where direct access will be an error.

Reference Links:

Http://www.cnblogs.com/weidiao/p/7389744.html

Http://www.cnblogs.com/mzsg/p/5623494.html

Nginx configuration supports HTTPS and WSS (websocket) protocol

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.