NGINX 反向代理 websockets 并启用 SSL (wss://)? [英] NGINX to reverse proxy websockets AND enable SSL (wss://)?
问题描述
我对自己构建 NGINX 感到非常迷茫和陌生,但我希望能够在没有额外层的情况下启用安全的 websocket.
I'm so lost and new to building NGINX on my own but I want to be able to enable secure websockets without having an additional layer.
我不想在 websocket 服务器本身上启用 SSL,而是想使用 NGINX 向整个服务器添加 SSL 层.
I don't want to enable SSL on the websocket server itself but instead I want to use NGINX to add an SSL layer to the whole thing.
那里的每个网页都说我做不到,但我知道我可以!感谢任何人(我自己)可以告诉我怎么做!
Every web page out there says I can't do it, but I know I can! Thanks to whoever (myself) can show me how!
推荐答案
请注意,nginx 现在在 1.3.13 版本中支持 Websockets.使用示例:
Just to note that nginx has now support for Websockets on the release 1.3.13. Example of use:
location /websocket/ {
proxy_pass http://backend_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
您还可以查看 nginx 更改日志 和 WebSocket 代理 文档.
You can also check the nginx changelog and the WebSocket proxying documentation.
这篇关于NGINX 反向代理 websockets 并启用 SSL (wss://)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!