答案1
这里是如何使用 Apache 作为反向代理的说明。
- 启用模块:
a2enmod proxy proxy_http proxy_wstunnel
- 编辑
/etc/apache2/sites-enabled/ams.conf
文件
<VirtualHost *:443>
ServerName yourdomain.com
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/yourdomain.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
SSLCertificateChainFile /etc/apache2/ssl/yourchain.crt
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:5080/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:5080/$1 [P,L]
ProxyPass / http://localhost:5080/
ProxyPassReverse / http://localhost:5080/
</VirtualHost>
- 并重新启动 apache2 服务:
systemctl restart apache2