I would like Apache to work in the following manner:
I've attempted to do this several ways:
METHOD 1:
RewriteRule ^(.*) http://xxx.xxx.xxx:port/ [P]
RESULT: Redirect Loop, the remote IP is accessed a handful of times (can confirm by looking at logs on remote server). SERVER1's logs show a repetition of the following:
proxy: *: found reverse proxy worker for http://xxx.xxx.xxx/
mod_proxy.c(1020): Running scheme http handler (attempt 0)
mod_proxy_http.c(1973): proxy: HTTP: serving URL http://xxx.xxx.xxx/
proxy_util.c(2011): proxy: HTTP: has acquired connection for (*)
proxy_util.c(2067): proxy: connecting http://xxx.xxx.xxx/ to xxx.xxx.xxx:80
proxy_util.c(2193): proxy: connected / to xxx.xxx.xxx:80
proxy_util.c(2444): proxy: HTTP: fam 2 socket created to connect to *
proxy_util.c(2576): proxy: HTTP: connection complete to xxx.xxx.xxx:80 (xxx.xxx.xxx)
mod_proxy_http.c(1743): proxy: start body send
mod_proxy_http.c(1847): proxy: end body send
proxy_util.c(2029): proxy: HTTP: has released connection for (*)
METHOD 2:
<VirtualHost *:801>
ServerName SERVER1
ProxyRequests Off
ProxyPreserveHost On
<Proxy *:801>
Order deny,allow
Allow from localhost
</Proxy>
ProxyPass / http://xxx.xxx.xxx/
ProxyPassReverse / http://xxx.xxx.xxx/
LogLevel debug
</VirtualHost>
and
RewriteRule ^(.*) http://127.0.0.1:801/ [PT]
RESULT: 400 Bad Request With method2, i can go to SERVER1:801 in my browser and everything works as expected.
Any help is GREATLY appreciated! Thanks in advance!
The solution ended up being a combination of several different tools in apache:
ProxyPassInterpolateEnv On
and the interpolate
keyword at the end of the ProxyPass
and ProxyPassReverse
statements) Apache:
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from localhost
</Proxy>
RewriteEngine On
ProxyPassInterpolateEnv On
RewriteMap subdomains txt:/directory/clients.txt
RewriteCond %{HTTP_HOST} ^(.*)\.application\.com
RewriteRule ^ - [E=SERVER_NAME:${subdomains:%1}]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ %{REQUEST_URI}/ [R]
ProxyPass / http://${SERVER_NAME}/ interpolate
ProxyPassReverse / http://${SERVER_NAME}/ interpolate