web頁面鏈接rabbit用了 sockjs.min.js、stomp.js
var ws = new SockJS('http://xxx.xxx.xxx.xxx:15674/stomp');
我的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直接安裝證書沒有裝成功,後面裝上了在寫。。。
本文當做筆記記錄下