繁体   English   中英

Apache HTTP 转发代理到多个目的地

[英]Apache HTTP forward proxy to multiple destinations

我正在尝试将 apache HTTP 服务设置为转发代理,可以将一些请求代理到另一个代理服务器和其他请求直接。 我有一个配置如下的虚拟主机

<VirtualHost 10.1.1.3:9000>
  ServerName 0.0.0.0
  DocumentRoot "/var/www/html"
  <Directory "/var/www/htm">
    AllowOverride All
    Options -Indexes +FollowSimLinks
    Require all granted
  </Directory>
  ProxyRequests On
  ProxyVia On
  SSLProxyEngine On
  ProxyPreserveHost On
  ProxyTimeout 60
  ProxyRemote "*" "http://otherproxy:8088"
  <ProxyMatch "^https?:\/\/my.*\.internal.*">
    ProxyPass "https://my.website.internal"
  </ProxyMatch>
</VirtualHost>

但是,每当我尝试通过代理进行路由时,都会收到 HTTP 503 错误。 它似乎正在选择 ProxyRemote 指令

[internal-server]$ https_proxy=http://10.1.1.3:9000 curl -kLv https://my.website.internal
....
Received HTTP code 503 from proxy after CONNECT
[internal-server]$ https_proxy=http://10.1.1.3:9000 curl -kLv https://github.com
....
< HTTP/1.1 200 OK
....
<!doctype html> .....

我发现这样做的方法是使用多个 VirtualHosts 和通配符 ServerAlias 指令。

# Default - Send all request to proxy to outside world
<VirtualHost 10.1.1.3:9000>
  ServerName 0.0.0.0
  ProxyRequests On
  ProxyVia On
  SSLProxyEngine On
  ProxyPreserveHost On
  ProxyTimeout 60
  ProxyRemote "*" "http://otherproxy:8088"
</VirtualHost>

# don't proxy specific internal domains
<VirtualHost 10.1.1.3:9000>
  ServerName direct.internal
  ServerAlias *.somedomain.internal
  ServerAlias *.anotherinternal.domain
  ProxyRequests On
  ProxyVia On
  SSLProxyEngine On
  ProxyPreserveHost On
  ProxyTimeout 60
</VirtualHost>

暂无
暂无

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

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