0

我目前正在使用 apache 作为反向代理(“发送”)到另一个 apache 服务器(“接收”)

我想在这 2 台服务器之间启用ProxyProtocol

接收mod_remoteip端,我可以简单地使用(https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html#remoteipproxyprotocol)“启用”代理协议

但是我如何让发送的apache 服务器实现它呢?我将 ProxyPass 用于常规 HTTP(s) 流量,并将 RewriteRule 与 [P] 用于 WebSocket:

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName x.y.z

    SSLEngine on

    SSLCertificateFile    /etc/letsencrypt/live/xyz/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/xyz/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/xyz/chain.pem

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine On
    ProxyPreserveHost On

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://receiving-host/$1 [P,L]

    ProxyPassMatch ^/.well-known !
    ProxyPass / http://receiving-host/
    ProxyPassReverse / http://receiving-host/

    RequestHeader set "X-Real-IP" "%{REMOTE_ADDR}s"
    RequestHeader set "X-Forwarded-Proto" "%{REQUEST_SCHEME}s"
</VirtualHost>

4

0 回答 0