{"id":126,"date":"2019-07-15T15:16:53","date_gmt":"2019-07-15T07:16:53","guid":{"rendered":"http:\/\/www.cgh0610.cn\/?p=126"},"modified":"2019-07-15T15:16:53","modified_gmt":"2019-07-15T07:16:53","slug":"nginx-%e9%85%8d%e7%bd%aewss","status":"publish","type":"post","link":"https:\/\/www.cgh0610.cn\/?p=126","title":{"rendered":"Nginx \u914d\u7f6ewss"},"content":{"rendered":"<p>\u6700\u8fd1\u5c0f\u7a0b\u5e8f\u7528\u5230WebSockets\uff0c\u670d\u52a1\u5668\u5b89\u88c5\u5b8c\u73af\u5883\u548c\u914d\u7f6e\u5b8cnginx\u914d\u7f6e\u540e\u8001\u662f\u51fa\u73b0\u9519\u8bef\u4ee3\u78011006\uff1b\u767e\u601d\u4e0d\u5f97\u5176\u59d0\u4e4b\u540e\uff0c\u6000\u7591\u662f\u56e0\u4e3a\u81ea\u5df1nginx\u8f6c\u53d1\u914d\u7f6e\u9519\u4e86<br \/>\n\u6700\u540e\u53d1\u73b0\uff0cwss\u914d\u7f6e\u9700\u8981\u914d\u7f6e\u5728ssl\u914d\u7f6e\u4e0b\uff0c\u800c\u6211\u5199\u9519\u5730\u65b9\u4e86\uff0c\u4e0b\u9762\u5217\u51fa\u6b63\u786e\u7684\u914d\u7f6e<\/p>\n<pre><code class=\"language-shell line-numbers\"><br \/>    location \/wss\/\n    {\n            proxy_pass http:\/\/127.0.0.1:2345;\n            proxy_set_header X-Real-IP <span class=\"katex math inline\">remote_addr;\n            proxy_set_header Host<\/span>host;\n            proxy_set_header X-Forwarded-For <span class=\"katex math inline\">proxy_add_x_forwarded_for;\n            proxy_http_version 1.1;\n            proxy_set_header Upgrade<\/span>http_upgrade;\n            proxy_set_header Connection \"upgrade\";\n            rewrite \/wss\/(.*) \/$1 break;\n            proxy_redirect off;\n    }\n<\/code><\/pre>\n<p>\u670d\u52a1\u5668nginx\u5b8c\u6574\u914d\u7f6e<\/p>\n<pre><code class=\"language-shell line-numbers\">server {\n        listen       80;\n        root \/www\/web\/app_xxx_com\/public_html;\n        server_name app.xxx.com;\n        index index.php;\n        error_page  400 \/errpage\/400.html;\n        error_page  403 \/errpage\/403.html;\n        error_page  404 \/errpage\/404.html;\n        error_page  503 \/errpage\/503.html;\n        location ~ \\.php<span class=\"katex math inline\">{\n                proxy_pass http:\/\/127.0.0.1:88;\n                include naproxy.conf;\n        }\n        location ~ \/\\.ht {\n                deny  all;\n        }\n        location \/ {\n                try_files<\/span>uri @apache;\n        }\n\n        location @apache {\n                 internal;\n                 proxy_pass http:\/\/127.0.0.1:88;\n                 include naproxy.conf;\n        }\n}\n\nserver {\n        listen       443;\n        root \/www\/web\/app_xxx_com\/public_html;\n        ssl                  on;\n        ssl_certificate      cert\/app.xxx.com.pem;\n        ssl_certificate_key  cert\/app.xxx.com.key;\n        ssl_prefer_server_ciphers on;\n        ssl_session_timeout 10m;\n        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n        ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;\n        server_name app.xxx.com;\n        index index.php;\n        error_page  400 \/errpage\/400.html;\n        error_page  403 \/errpage\/403.html;\n        error_page  404 \/errpage\/404.html;\n        error_page  503 \/errpage\/503.html;\n        location ~ \\.php<span class=\"katex math inline\">{\n                proxy_pass http:\/\/127.0.0.1:88;\n                include naproxy.conf;\n        }\n        location ~ \/\\.ht {\n                deny  all;\n        }\n        location \/ {\n                try_files<\/span>uri @apache;\n        }\n        location @apache {\n                 internal;\n                 proxy_pass http:\/\/127.0.0.1:88;\n                 include naproxy.conf;\n        }\n        location \/wss {\n                 proxy_pass http:\/\/127.0.0.1:2345;\n                 proxy_http_version 1.1;\n                 proxy_set_header Upgrade <span class=\"katex math inline\">http_upgrade;\n                 proxy_set_header Connection \"Upgrade\";\n                 proxy_set_header X-Real-IP<\/span>remote_addr;\n        }\n\n}\n\n<\/code><\/pre>\n<p>\u53c2\u8003\u94fe\u63a5\uff1a<a href=\"https:\/\/wenda.workerman.net\/question\/1485\">https:\/\/wenda.workerman.net\/question\/1485<\/a><br \/>\n<a href=\"https:\/\/blog.csdn.net\/Phoenix_smf\/article\/details\/89278398\">https:\/\/blog.csdn.net\/Phoenix_smf\/article\/details\/89278398<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5c0f\u7a0b\u5e8f\u7528\u5230WebSockets\uff0c\u670d\u52a1\u5668\u5b89\u88c5\u5b8c\u73af\u5883\u548c\u914d\u7f6e\u5b8cnginx\u914d\u7f6e\u540e\u8001\u662f\u51fa\u73b0\u9519\u8bef\u4ee3\u78011006\uff1b\u767e\u601d\u4e0d\u5f97 &hellip; <a href=\"https:\/\/www.cgh0610.cn\/?p=126\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Nginx \u914d\u7f6ewss<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":[],"categories":[3],"tags":[55,54,4,53],"_links":{"self":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts\/126"}],"collection":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=126"}],"version-history":[{"count":1,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}