nodebb下Apache配置ssl導(dǎo)致websocket/wss失效出現(xiàn)400錯(cuò)誤的解決方案

[重要通告]如您遇疑難雜癥,本站支持知識(shí)付費(fèi)業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時(shí)間哦!

請(qǐng)確保apache 最低版本2.4以上
參考官方proxy文檔 配置443端口
Configuring Apache as a proxy

<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com

# Rewrite any http traffic to the main url https site
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^[^\/]*\/(.*) https://www.example.com/$1 [R=301,L]
</IfModule>
</VirtualHost>

<VirtualHost *:443>
Protocols h2 http/1.1
ServerName www.example.com

# your SSL證書
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/privkey.pem
SSLCertificateChainFile /path/to/chain.pem

# Basic security headers
Header always set X-Content-Type-Options "nosniff"
Header always set X-Xss-Protection "1; mode=block"

# NodeBB header
RequestHeader set X-Forwarded-Proto "https"

# Static file cache
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 14 days"
Header set Cache-Control "public"
</IfModule>
</FilesMatch>

ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

# Custom Error Document when NodeBB is offline
ProxyPass /error-documents !
ErrorDocument 503 /error-documents/503.html
Alias /error-documents /path/to/nodebb/public

# Websocket passthrough 4567是你當(dāng)前的端口
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:4567/$1 [P,L]

ProxyPass / http://localhost:4567/
ProxyPassReverse / http://localhost:4567/

# Log stuff
ErrorLog ${APACHE_LOG_DIR}/www-example-error.log
CustomLog ${APACHE_LOG_DIR}/www-example-access.log combined
</VirtualHost>

不修改socket的配置 到這一步應(yīng)該就可以了
如果遇到session-ID失效的問(wèn)題 ,看看是不是nodebb config.json域名是否正確,socketio配置是否正確
https://community.nodebb.org/topic/4383/hundreds-of-polling-requests/34

{
"url": "https://your domain",
"secret": "e79feff0-b6b6-4d36-8389-c7fdbc52f171",
"database": "mongo",
"mongo": {
"host": "yourt host",
"port": "your database prot",
"username": "your name",
"password": "your pass",
"database": "your database",
"uri": ""
},
"socket.io": {
"transports": ["websocket"]
}
}

改完之后如果無(wú)效嘗試下重啟服務(wù)和nodebb

問(wèn)題未解決?付費(fèi)解決問(wèn)題加Q或微信 2589053300 (即Q號(hào)又微信號(hào))右上方掃一掃可加博主微信

所寫所說(shuō),是心之所感,思之所悟,行之所得;文當(dāng)無(wú)敷衍,落筆求簡(jiǎn)潔。 以所舍,求所獲;有所依,方所成!

支付寶贊助
微信贊助

免責(zé)聲明,若由于商用引起版權(quán)糾紛,一切責(zé)任均由使用者承擔(dān)。

您必須遵守我們的協(xié)議,如您下載該資源,行為將被視為對(duì)《免責(zé)聲明》全部?jī)?nèi)容的認(rèn)可->聯(lián)系老梁投訴資源
LaoLiang.Net部分資源來(lái)自互聯(lián)網(wǎng)收集,僅供用于學(xué)習(xí)和交流,請(qǐng)勿用于商業(yè)用途。如有侵權(quán)、不妥之處,請(qǐng)聯(lián)系站長(zhǎng)并出示版權(quán)證明以便刪除。 敬請(qǐng)諒解! 侵權(quán)刪帖/違法舉報(bào)/投稿等事物聯(lián)系郵箱:service@laoliang.net
意在交流學(xué)習(xí),歡迎贊賞評(píng)論,如有謬誤,請(qǐng)聯(lián)系指正;轉(zhuǎn)載請(qǐng)注明出處: » nodebb下Apache配置ssl導(dǎo)致websocket/wss失效出現(xiàn)400錯(cuò)誤的解決方案

發(fā)表回復(fù)

本站承接,網(wǎng)站推廣(SEM,SEO);軟件安裝與調(diào)試;服務(wù)器或網(wǎng)絡(luò)推薦及配置;APP開(kāi)發(fā)與維護(hù);網(wǎng)站開(kāi)發(fā)修改及維護(hù); 各財(cái)務(wù)軟件安裝調(diào)試及注冊(cè)服務(wù)(金蝶,用友,管家婆,速達(dá),星宇等);同時(shí)也有客戶管理系統(tǒng),人力資源,超市POS,醫(yī)藥管理等;

立即查看 了解詳情