0

I have an open server that's running Apache and a closed server that's also running Apache and that's behind a firewall and running a VPN.

I'm trying to forward requests from a sub domain to the closed server using the open server. subdomain.request.com -> open server -> closest server

My understanding is that this can be achieved using Apache's mod proxy but I'm having difficulty setting it up. I'm able to request the home page but all other pages produce a DNS lookup failure error.

vhost

<VirtualHost *:80> ServerName subdomain.request.com ProxyPass / http://10.0.0.54:8080 ProxyPassReverse / http://10.0.0.54:8080 ProxyPassMatch ^/(.*)$ http://10.0.0.54:8080/$1i </VirtualHost>

2 Answers2

2

Garreth is almost correct but you have to do the opposite:

<VirtualHost *:80>
ServerName subdomain.request.com
RewriteEngine On
ProxyPreserveHost On
RewriteRule ^/(.*)$ http://10.0.0.54:8080/$1 [P,QSA,L]
</VirtualHost>

This way the server at 10.0.0.54 will receive the original "Host: " Header ( aka: subdomain.request.com , not 10.0.0.54 ) and since the server at 10.0.0.54 might be creating links based on this header this will probably solve your problem.

My guess is that the error you have is not a dns error but a network error, because with your setup the server generates urls looking like: http://10.0.0.54... and these urls are not reachable from the internet ( because 10.0.0.54 is a private network behind your vpn ).

With ProxyPreserveHost On your server will generate links to: http://subdomain.request.com...

Olivier S
  • 2,739
  • 1
  • 14
  • 14
1

In this scenario, its easier to use the proxy function [P] in mod_rewrite

<VirtualHost *:80>
ServerName subdomain.request.com
RewriteEngine On
RewriteRule ^/(.*)$ http://10.0.0.54:8080/$1 [P,QSA,L]
</VirtualHost>

You should also be aware of the ProxyPreserveHost Directive

ProxyPreserveHost On|Off

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost

If you have this set to on on your Proxy, it will pass the hostname you are looking for through to mod_proxy, and if mod_proxy can't resolve that, it will give you a DNS error.

Garreth McDaid
  • 3,449
  • 1
  • 27
  • 42
  • In you're example, is it routing the request through the first server or just kicking the request over to the seconds? Using ProxyPass I'm able to bring up the home page but any other page results in the DNS error mentioned above. – ScreamingPlastic Mar 25 '14 at 14:11
  • It is "proxying" the request. – Garreth McDaid Mar 25 '14 at 17:19
  • Seems to be but it looks like it's only matching on the slash (index page). So I'm not sure if it's my ProxyPassMatch or something else. – ScreamingPlastic Mar 25 '14 at 18:35
  • ProxyPreserveHost will not resolve anything. You have to set it on if you want to send the destination server the original Host: http header ( instead of: "10.0.0.54" ) – Olivier S Mar 26 '14 at 19:46