nodebb下Apache配置ssl导致websocket/wss失效出现400错误的解决方案
[重要通告]如您遇疑难杂症,本站支持知识付费业务,扫右边二维码加博主微信,可节省您宝贵时间哦!
请确保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是你当前的端口 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的配置 到这一步应该就可以了
如果遇到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"] } }
改完之后如果无效尝试下重启服务和nodebb
问题未解决?付费解决问题加Q或微信 2589053300 (即Q号又微信号)右上方扫一扫可加博主微信
所写所说,是心之所感,思之所悟,行之所得;文当无敷衍,落笔求简洁。 以所舍,求所获;有所依,方所成!
赏
支付宝赞助
微信赞助
免责声明,若由于商用引起版权纠纷,一切责任均由使用者承担。
您必须遵守我们的协议,如您下载该资源,行为将被视为对《免责声明》全部内容的认可->联系老梁投诉资源 LaoLiang.Net部分资源来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系站长并出示版权证明以便删除。
敬请谅解! 侵权删帖/违法举报/投稿等事物联系邮箱:service@laoliang.net
意在交流学习,欢迎赞赏评论,如有谬误,请联系指正;转载请注明出处: » nodebb下Apache配置ssl导致websocket/wss失效出现400错误的解决方案