天天看点

HTTPS站点使用sockjs+rabbitmq问题

web页面链接rabbit用了 sockjs.min.js、stomp.js

var ws = new SockJS('http://xxx.xxx.xxx.xxx:15674/stomp');
           
HTTPS站点使用sockjs+rabbitmq问题

我的rabbitmq 是没有配证书的,所以在https站点用sockjs链接下报错,如上图

解决办法是用服务器代理,比如我用的nginx

nginx.conf 中https站点的 server 中增加配置

location /stomp/ {
    proxy_pass http://backend;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}
           

nginx.conf 中httpd 中增加配置

upstream backend{
    server 203.111.222.333:15674; #rabbit 服务器ip+端口
}
           

web页面链接rabbit的js修改为

var ws = new SockJS('https://xxx.xxxxx.com/stomp');
           

链接正常。

给rabbit直接安装证书没有装成功,后面装上了在写。。。

本文当做笔记记录下

继续阅读