# WebSocketSecure SSL Endpoint
#
# The proxy is also an SSL endpoint for WSS and HTTPS connections.
# So the clients can use wss:// connections
# (e.g. from pages served via HTTPS) which work better with broken
# proxy servers, etc.
server {
listen 443;
# host name to respond to
server_name ws.example.com;
# your SSL configuration
ssl on;
ssl_certificate /etc/ssl/localcerts/ws.example.com.bundle.crt;
ssl_certificate_key /etc/ssl/localcerts/ws.example.com.key;
location / {
# switch off logging
access_log off;
# redirect all HTTP traffic to localhost:8080
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
4条答案
按热度按时间bbmckpt71#
我遇到了同样的问题,nginx https代理到tomcat.这是因为我还没有支持的wss请求.为了支持wss请求,我使用如下配置:
ac1kyiln2#
以下解决方案对我有效
我希望,这有助于...上面的解决方案是以下链接的一部分:https://forum.mattermost.org/t/solved-apache2-reverseproxy-with-websocket-https/437/3
carvr3hs3#
这个职位似乎关闭,但我没有找到一个确切的解决方案,所以我会为未来的需要后
我用反向代理配置解决了这个问题(在我的例子中是apache httpd)
首先,您必须在httpd.conf中启用一些mods
然后进入您的虚拟主机配置并使用以下规则
显然,用真实的url和端口替换[YOUR_URL]和[YOUT_PORT],如果使用的是安全Web套接字,则用“wss”替换“ws”
就是这样!
如果您在服务器中做了正确的事情,您可以阅读以下标题
fcg9iug34#
DefaultHandshakeHandler -“由于无效的升级标头,握手失败:空”
此处的URL应包含端口号
例如:ws://或wss://{baseUrl}:8080/您的WebSocket终结点
并在服务器上使用以下命令启用代理
您可以在www.example.com上阅读本文https://github.com/spring-projects/spring-framework/issues/16978#issuecomment-453418847