-1

I have two servers:

  • A (192.168.1.100:80)
  • B (192.168.1.200:8080)

Both are behind firewall and only port 80 is open and forwarded to server A.

People from outside type www.mydomain.com to access my web server A.

Now I would like all of the HTTP from subdomain.mydomain.com to go to server B.

1

You can use mod_proxy to do this.

You set up a host entry on A for subdomain.mydomain.com to point to B, and set up B to serve this domain. You then set up a virtual host on A for subdomain.mydomain.com. This virtual host will reverse proxy / to B.

ProxyPass / http://subdomain.mydomain.com/
ProxyPassReverse / http://subdomain.mydomain.com/
  • Sorry my ignorance. I added subdomain.mydomain.com to point to 192.168.1.200 hosts file and as I said the web server on B is run on 192.168.1.200:8080. Also, I added both directives to the site-availble/default file. However, it is still not working. I was wondering if someone request externally to subdomain.mydomain.com how it would get proxied to the other server. – jax Feb 22 '13 at 0:06
  • the external dns for the subdomain should be set to go to the external address for server A. Server A will then route the requests for the domain by proxying it to the backend. – drone.ah Feb 22 '13 at 13:55
0

To accomplish that you will need two virtual hosts and mod_proxy enabled.

In sites-enabled, you will want a file containing minimally this (and whatever other config you want):

<VirtualHost *:80>
   ServerName www.mydomain.com

   ... whatever you want to serve
</VirtualHost>
<VirtualHost *:80>
   ServerName subdomain.mydomain.com
   ProxyPass / http://subdomain.mydomain.com/
   ProxyPassReverse / http://subdomain.mydomain.com/
</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.