【发布时间】:2021-05-25 08:14:10
【问题描述】:
我在我的服务器上使用 Apache 代理端口 80 和 443 上的流量,以分隔运行不同网站和服务的 VM。我在为需要 websocket 的 MeshCentral 设置代理时遇到问题。我正在使用 Debian 10 和 Apache 2.4.38。
我可以加载 MeshCentral,但是一旦我登录它就会尝试使用 websockets 并且我收到以下错误;
Firefox can’t establish a connection to the server at wss://example.com/control.ashx?auth=Uu7PBFNsswzzWoQaVNPH2N3ZwkWbx7DSsljaaY8cxthO5fcPVSz@sqLbGzyOpvxTxvfmV7WgwLdRklqLNYC5KQTjrZPCYDcNDvJ0AY7V8DGdUk68jK3sPfnc$Sl7rvhaQwR1xBukiZ8=. meshcentral.js:27:21
我已经添加了 wstunnel 代理
a2enmod proxy_wstunnel
并设置正常工作的 HTTP 和 HTTPS 代理
/etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerName example.com
ProxyPreserveHost On
ProxyPass "/" "http://192.168.200.11/"
ProxyPassReverse "/" "http://example.com/"
</VirtualHost>
/etc/apache2/sites-enabled/000-default-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
RewriteEngine on
RewriteCond ${HTTP:UPGRADE} websocket [NC]
RewriteCond ${HTTP:CONNECTION} upgrade [NC]
RewriteRule /(.*) "wss://example.com/$1" [P]
ProxyPreserveHost On
ProxyPass "/" "https://192.168.200.11/"
ProxyPassReverse "/" "https://example.com/"
SSLProxyEngine On
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
</VirtualHost>
</IfModule>
在尝试在 firefox 中加载页面之前,我已经重新启动了 apache,还尝试了 google-chrome,同样的错误。
【问题讨论】:
标签: apache websocket reverse-proxy