【发布时间】:2020-08-15 20:26:01
【问题描述】:
我有一个在k8s 下运行的jetty Web 应用程序。这个网络应用程序有一个 websocket 端点。部署的服务通过https 上的nginx 入口公开。
一切正常,我的 web 应用程序正在运行,websockets 工作正常(即消息被推送和接收),但 websockets 关闭时出现1006 错误代码,老实说,这并没有阻止我的代码工作但也不好看。
websocket 暴露@/notifications。在“正常”配置中,即不是k8s,只是安装在虚拟机上的普通软件,我需要将以下内容添加到nginx.conf
location /notifications {
proxy_pass http://XXX/notifications;
proxy_read_timeout 3700s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Origin '';
}
我尝试通过入口这样做
nginx.ingress.kubernetes.io/configuration-sn-p: |
location /notifications {
proxy_pass http://webapp:8080/notifications;
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
}
但是没有效果,即我检查了生成的nginx.conf,并没有添加这样的块...
以前有人遇到过这样的问题吗?关于如何解决1006 问题的任何线索?
【问题讨论】:
标签: nginx kubernetes websocket jetty kubernetes-ingress