使用 Apache2 作為反向代理重定向到 URI

使用 Apache2 作為反向代理重定向到 URI

我正在使用 Apache2 運行反向代理,並且配置了以下 vHost:

<VirtualHost *:80>
        ServerName rds.example.com
        Redirect / https://rds.example.com/RDWeb/
</VirtualHost>
<VirtualHost *:443>
        # Proxy
        ServerName rds.example.com
        ProxyPreserveHost on
        SSLProxyEngine on
        SSLProxyVerify off
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off
        SSLProxyCheckPeerExpire off
        ProxyPass / https://backend01.example.com/
        ProxyPassReverse / https://backend01.example.com/
SSLCertificateFile /etc/letsencrypt/live/rds.example.com//fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/rds.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

當客戶端連接到http://rds.example.com或者https://rds.example.com,我想把他重新導向到https://rds.example.com/RDWeb(微軟預設的遠端桌面Web服務)。

實際上,當客戶端連線時,他只會被重新導向到https://rds.example.com與漂亮的 IIS 頁面。

我究竟做錯了什麼 ?

答案1

您可以使用mod_rewrite重定向到您想要的位置 - 將其整合到 SSL 虛擬主機中:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule .* /RDWeb/ [R,L]

不要忘記啟用 mod_rewrite (a2enmod如果可能的話使用)。

相關內容