[英]Apache HTTP forward proxy to multiple destinations
I'm trying to set up an apache HTTP service as a forward proxy that can proxy some requests to another proxy server and other requests directly.我正在尝试将 apache HTTP 服务设置为转发代理,可以将一些请求代理到另一个代理服务器和其他请求直接。 I have a Virtual host configured like
我有一个配置如下的虚拟主机
<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>
However, whenever I try to route through the proxy I get an HTTP 503 error.但是,每当我尝试通过代理进行路由时,都会收到 HTTP 503 错误。 It seems to be selecting the ProxyRemote directive
它似乎正在选择 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> .....
The way I found to do this was by using multiple VirtualHosts and wildcard ServerAlias directives.我发现这样做的方法是使用多个 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.