请确保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