我经常使用Apache使用ProxyPass和ProxyPassReverse将代理服务器反向代理到其他服务器。 我一直在做这个顶级文件夹。 但现在我有要求将网站的主页放在新的CMS服务器上。
反向代理主页的最佳方式是什么(对于请求:GET / HTTP / 1.1),而不影响每个请求?
我想我可以列出服务器上的每个目录和顶级页面! 指示。 但是肯定有更好的办法。
所有的帮助感激地收到。
ProxyPass指令按照第一个匹配的顺序进行处理,只需将最后一个匹配到CMS,例如
ProxyPass /app1 http://app1.example.org/app1 ProxyPassReverse /app1 http://app1.example.org/app1 ProxyPass /app2 http://app2.example.org/app2 ProxyPassReverse /app2 http://app2.example.org/app2 ProxyPass / http://cms.example.org/ ProxyPassReverse / http://cms.example.org/
或者,希望一个行为良好的CMS,只有主着陆页在根目录下,所有脚本,图像和其他内容都在适当的子目录中:
# Redirect requests to www.example.org/ to www.example.org/index.html RewriteRule ^/$ /index.html ProxyPass /index.html http://cms.example.org/index.html ProxyPass /css http://cms.example.org/css ProxyPassReverse /css http://cms.example.org/css ProxyPass /img http://cms.example.org/img ProxyPassReverse /img http://cms.example.org/img