简体   繁体   English

Apache VirtualHost 指令 ProxyPass

[英]Apache VirtualHost directive ProxyPass

I want to use Apache as a proxy for two different sites hosted on different machines.我想使用 Apache 作为托管在不同机器上的两个不同站点的代理。 I am currently running Apache 2.2.15.我目前正在运行 Apache 2.2.15。

What I want to achieve is:我想要实现的是:

 Client --> https://ApacheWebProxyPubIP:443
        --> /Url1.php --> http://10.0.0.2/Url1.php
        --> /Url2 --> http://10.0.0.3/Url2

I tried using:我尝试使用:

VirtualHost default:443
         ServerName something.nice.org
         ProxyPass /Url1.php http://10.0.0.2/Url1.php
         ProxyPassReverse /Url1.php http://10.0.0.2/Url1.php
     VirtualHost
     VirtualHost *:443
         ServerName somethingelse.nice.org
         ProxyPass /Url2 http://10.0.0.3/Url2
         ProxyPassReverse /Url2 http://10.0.0.3/Url2
     VirtualHost *:443

The /Url1.php to http://10.0.0.2/Url1.php works fine but Url2 is not forwarded to 10.0.0.3. /Url1.php 到http://10.0.0.2/Url1.php工作正常,但 Url2 没有转发到 10.0.0.3。

What would be the correct syntax to achieve this?实现这一目标的正确语法是什么?

Thanks!谢谢!

Try this in your <VirtualHost> directive:在您的<VirtualHost>指令中试试这个:

     ServerName something.nice.org
     ServerAlias somethingelse.nice.org

     ProxyPass /Url1.php http://10.0.0.2/Url1.php
     ProxyPassReverse /Url1.php http://10.0.0.2/Url1.php

     ProxyPass /Url2 http://10.0.0.3/Url2
     ProxyPassReverse /Url2 http://10.0.0.3/Url2

Use the使用

ProxyPreserveHost yes

directive.指令。 Tells the forwarding server to preserve the host name (which is forwarded by the client).告诉转发服务器保留主机名(由客户端转发)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM