Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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/
share|improve this answer
    
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. –  arashaga 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

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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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