![使用 Apache2 作為反向代理重定向到 URI](https://rvso.com/image/1628798/%E4%BD%BF%E7%94%A8%20Apache2%20%E4%BD%9C%E7%82%BA%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E9%87%8D%E5%AE%9A%E5%90%91%E5%88%B0%20URI.png)
我正在使用 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
如果可能的話使用)。