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. 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. It seems to be selecting the ProxyRemote directive
[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.
# 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.