Nginx Reverse proxy WebSocket

Source: Internet
Author: User
Tags nginx reverse proxy


Description: Http://www.oschina.net/translate/websocket-nginx

After reading the instructions, start the configuration directly:



Add the following configuration in nginx.conf

Include testws.conf;

Include testwss.conf;



Vim testws.conf

Map $http _upgrade $connection _upgrade {default upgrade; ' Close;} Upstream WebSocket {server 10.0.0.x:6020;}    server {server_name yourdomain;    Listen 80;    Access_log Logs/xx.access.log Main;        Location/{Proxy_pass Http://websocket;        Proxy_http_version 1.1;        Proxy_set_header Upgrade $http _upgrade;    Proxy_set_header Connection "Upgrade"; }}





Vim testwss.conf

map    $http _upgrade  $connection _upgrade {      default  upgrade;       '  close;} upstream websocket1 {    server 10.0.0.x:6020;} server {   server_name yourdomain;   listen 443;    ssl  on;   ssl_certificate xxxx.crt;   ssl_certificate_key  xxxx.key;   ssl_session_timeout  5m;   ssl_protocols   tlsv1 tlsv1.1 tlsv1.2;   ssl_ciphers  high:! rc4:! md5:!anull:!enull:! Null:! Dh:! edh:! Exp:+medium;   ssl_prefer_server_ciphers   on;    access_log   logs/xx.access.log  main;    location   /   {        proxy_pass http://websocket1;        proxy_http_version 1.1;         proxy_set_header Upgrade  $http _upgrade;         proxy_set_header Connection  "Upgrade";     }}




This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1874319

Nginx Reverse proxy WebSocket

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.