Nginx 代理 WebSocket

http {
    include       mime.types;
    default_type  application/octet-stream;
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
    
    
#   webSocket配置配置信息
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }
#   指定websocket服务
    upstream websocket {
            server 127.0.0.1:8085;
    }
 
    server{
            listen 8087;
            location / {
                    #  引用
                    proxy_pass http://websocket;
                    proxy_read_timeout 300s;
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP $remote_addr;
                    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 $connection_upgrade;
               }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    }
 
}
上一篇:JavaScript自学代码--(四)


下一篇:idea配置默认maven仓库路径