HTTPS站點使用sockjs+rabbitmq問題

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直接安裝證書沒有裝成功,後面裝上了在寫。。。

本文當做筆記記錄下

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章