【发布时间】:2022-11-09 08:01:04
【问题描述】:
我的 spring boot websocket(ws) 端点可以在 localhost 上使用 angular (rxstomp) 正常工作。
prod 服务器使用 nginx (https),我无法连接到 ws。 FE 和 BE 在 docker 中的同一台服务器上,在不同的 url 上。
Nginx 配置:
location /ws {
...
proxy_pass http://backend/ws
...
}
BE:
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws")
.setAllowedOrigins(frontendUrl);
}
FE:
export function rxStompServiceFactory() {
const rxStomp = new RxStompService();
rxStomp.configure(myRxStompConfig);
rxStomp.activate();
return rxStomp;
}
export const myRxStompConfig: RxStompConfig = {
brokerURL: 'ws://localhost:8088/ws',
...
请帮忙
谢谢
【问题讨论】:
-
nginx 中的上游是如何定义的?你得到的错误是什么? nginx日志中的任何内容?
-
上游 apitest { ip_hash;服务器 127.0.0.1:8085 max_fails=1 fail_timeout=6s;服务器 127.0.0.1:8086 max_fails=1 fail_timeout=6s;保活 16; }
-
LOG: 2022/10/17 14:30:31 [crit] 223719#223719: *2929 SSL_do_handshake() 在 SSL 握手时失败(SSL: error:14201044:SSL routines:tls_choose_sigalg:internal error),客户端:[IP],服务器:0.0.0.0:443
-
如果我没看错的话,您在 apitest 上游定义的负载平衡后面有 2 台服务器。但是,proxypass 设置为后端,所以这里不匹配......
标签: angular spring-boot nginx wss ws