nodebb下Apache配置ssl導(dǎo)致websocket/wss失效出現(xiàn)400錯誤的解決方案
[重要通告]如您遇疑難雜癥,本站支持知識付費(fèi)業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時間哦!
請確保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失效的問題 ,看看是不是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ù)和nodebb
問題未解決?付費(fèi)解決問題加Q或微信 2589053300 (即Q號又微信號)右上方掃一掃可加博主微信
所寫所說,是心之所感,思之所悟,行之所得;文當(dāng)無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!
賞
支付寶贊助
微信贊助
免責(zé)聲明,若由于商用引起版權(quán)糾紛,一切責(zé)任均由使用者承擔(dān)。
您必須遵守我們的協(xié)議,如您下載該資源,行為將被視為對《免責(zé)聲明》全部內(nèi)容的認(rèn)可->聯(lián)系老梁投訴資源 LaoLiang.Net部分資源來自互聯(lián)網(wǎng)收集,僅供用于學(xué)習(xí)和交流,請勿用于商業(yè)用途。如有侵權(quán)、不妥之處,請聯(lián)系站長并出示版權(quán)證明以便刪除。
敬請諒解! 侵權(quán)刪帖/違法舉報/投稿等事物聯(lián)系郵箱:service@laoliang.net
意在交流學(xué)習(xí),歡迎贊賞評論,如有謬誤,請聯(lián)系指正;轉(zhuǎn)載請注明出處: » nodebb下Apache配置ssl導(dǎo)致websocket/wss失效出現(xiàn)400錯誤的解決方案