你好,我正在寻找一种使用 apache2 通过 Websocket 反向代理网站的方法,但网站和反向代理在不同的隔离服务器上运行。
我已尝试使用正常方式进行配置,但我的设置不起作用。
<VirtualHost *:443>
ServerName domain
ProxyPreserveHost On
ProxyRequests off
<Location />
ProxyPass http://ip:80/
ProxyPassReverse http://ip:80/
</Location>
<Location /sub>
ProxyPass wss://ip:443/
ProxyPassReverse wss://ip:443/
</Location>
RewriteEngine on
RewriteRule ^/\.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^/\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
RewriteRule ^/\.well-known/webfinger /index.php/.well-known/webfinger [R=301,L]
RewriteRule ^/\.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^/\.well-known/caldav /remote.php/dav/ [R=301,L]
RewriteRule ^/\.well-known/nodeinfo /index.php/.well-known/nodeinfo [R=301,L]
RewriteCond ${HTTP:Upgrade} websocket [NC]
RewriteCond ${HTTP:Connection} upgrade [NC]
RewriteRule .* "wss:/ip:443/$1" [P,L]
Protocols h2 http/1.1
Header always set Strict-Transport-Security: "max-age=63072000; includeSubDomains; preload"
Header set Content-Security-Policy "frame-ancestors 'self';"
SSLEngine on
SSLProtocol all -SSLv3 +TLSv1.2 +TLSv1.3
SSLHonorCipherOrder on
SSLSessionTickets off
SSLUseStapling on
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors off
SSLCertificateFile /etc/letsencrypt/live/cert/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cert/privkey.pem
</VirtualHost>
apache错误日志:
[Wed May 10 16:31:11.198085 2023] [proxy:error] [pid 54233:tid 139683125876288] (111)Connection refused: AH00957: wss: attempt to connect to ip:443 (ip:443) failed
[Wed May 10 16:31:11.198130 2023] [proxy_http:error] [pid 54233:tid 139683125876288] [client ip:52037] AH01114: HTTP: failed to make connection to backend: ip