我有一个运行在Docker容器上的网站,并且在主机的Apache上创build了一个虚拟主机,这个虚拟主机正在对容器做一个反向代理(在主机的8280端口上)。 所以我有:
<VirtualHost *:443> ServerName www.example.com DirectoryIndex index.php index.html SetOutputFilter SUBSTITUTE,DEFLATE ProxyPass / http://localname:8280/ ProxyPassReverse / http://localname:8280/ Substitute "s|http://localname:8280/|https://www.example.com/|i" SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW SSLCertificateKeyFile /path-to/privkey.pem SSLCertificateFile /path-to/cert.pem SSLCertificateChainFile /path-to/chain.pem <Proxy *> Order deny,allow Allow from all Allow from localhost </Proxy> </VirtualHost> <VirtualHost *:80> ServerName www.example.com ServerAlias www.example.com Redirect permanent / https://www.example.com/ </VirtualHost>
代理工作得很好,我在浏览器中编写www.example.com时有一个响应,但是我有所有指向http:// localname:8280的链接(如浏览器控制台所示)以及混合内容错误,这就是为什么我已经把替代指令,但它不工作。
我正在使用apache文档的mod_substituteconfiguration。
https://httpd.apache.org/docs/2.4/mod/mod_substitute.html
但是这不起作用,什么都改变了。 docker容器基于默认configuration的bitnami / apache映像。
任何帮助,将不胜感激。
好的,我自己find了答案。 您只需在replace指令中添加以下行:
AddOutputFilterByType SUBSTITUTE text/html