Apache反向代理:在链接中更改协议,并将目标从http转换为https

我有一个HTTP服务运行在10.1.1.187:8080。

这是作为一个公共https服务交付到https://public.example.com这是通过Apache代理魔术10.1.1.186:443:

<VirtualHost 10.1.1.186:443> ServerName public.example.com #Configure Reverse Proxy ProxyRequests Off ProxyPreserveHost On <Location /> ProxyPass http://10.1.1.187:8080/ ProxyPassReverse http://10.1.1.187:8080/ Order allow,deny Allow from all </Location> #Define Virtual Host Specific SSL information. SSLEngine On SSLProxyEngine On SSLProxyProtocol all -SSLv2 SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key </VirtualHost> 

当我在浏览器中inputhttps://public.example.com并点击证书时,我可以得到包含login表单的第一页:

 <form action="http://public.example.com/login" method="post"> <-- ... contains username, password fields and a send button --> </form> 

所以行动目标是非常好的重写。 但是,http应该读取https。 怎么做?

如果链接已经在action标签中更改了,那么已经指向正确的https页面,而是使用第二个具有重写条件的http虚拟主机。

编辑:

这是解决它的额外部分(我把它放在虚拟主机,但在位置容器外):

 SetOutputFilter proxy-html # On: rewrite also css and javascript - Off: only in HTML ProxyHTMLExtended Off # Maybe this should be switched on ProxyHTMLURLMap http://public.example.com https://public.example.com 

您可以尝试http://apache.webthing.com/mod_proxy_html/ 。 它旨在重写URL在“代理情况”。