TeamCity,nginx和Websockets C 501错误
发布时间:2023-12-12 17:04:16 所属栏目:Nginx 来源:DaWei
导读: 我目前正在使用nginx反向代理设置TeamCity,但我的浏览器出错了.错误如下:
WebSocket connection to 'ws://ci.example.net/app/subscriptions?X-Atmosphere-tracking-id=0&X-Atmosphere-Fr
WebSocket connection to 'ws://ci.example.net/app/subscriptions?X-Atmosphere-tracking-id=0&X-Atmosphere-Fr
我目前正在使用nginx反向代理设置TeamCity,但我的浏览器出错了.错误如下: WebSocket connection to 'ws://ci.example.net/app/subscriptions?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.7-javascript&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&X-atmo-protocol=true&browserLocationHost=http%3A%2F%2Fci.example.net' failed: Error during WebSocket handshake: Unexpected response code: 501我查看了nginx错误日志和TeamCity错误日志,两者都显示为空. 我的nginx配置如下: server { listen 80; server_name ci.example.net; error_log /var/log/nginx/error.log; proxy_intercept_errors on; error_page 401 403 404 /404.html; location / { 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_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:8111; proxy_read_timeout 90; proxy_redirect http://127.0.0.1:8111 http://ci.fluxmc.net; } } #Websocket configuration map $http_upgrade $connection_upgrade { default upgrade; '' ''; } server { listen 400; server_name ci.example.net; error_log /var/log/nginx/error.log; proxy_intercept_errors on; location /tc { proxy_pass http://localhost:8111/tc; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $server_name:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } }我真的不确定从哪里开始,我几乎完全遵循了documentation for TeamCity.如果您能提供任何帮助,我将不胜感激! 最佳答案 TeamCity的文档使a couple of assumptions无法满足您的要求: TeamCity server is installed at URL: 07001 It is visible to the outside world as URL: 07002 在您的情况下,TeamCity对外界可见URL:http://ci.example.net. 这会改变您的NGINX配置,如下所示: server { listen 80; server_name ci.example.net; error_log /var/log/nginx/error.log; proxy_intercept_errors on; error_page 401 403 404 /404.html; location / { 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_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:8111; proxy_read_timeout 90; proxy_redirect http://127.0.0.1:8111 http://ci.fluxmc.net; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } #Websocket configuration map $http_upgrade $connection_upgrade { default upgrade; '' ''; }对我来说,这足以让TeamCity的websocket连接工作. (编辑:4S站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐