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 a CentOS5 server with Apache, which have one external IP address with the hostname "example.com".

What I like is that

sub1.example.com sends http requests to 10.10.10.10
sub2.example.com sends http requests to 10.20.20.20

Looking at the mod_proxy for Apache, I can't figure out what I need to configure to get that.

Does someone know how to do this?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You'll have to create two virtual hosts for apache one for each subdomain, acting as a reverse proxy to the specified ip.

something along the lines of

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName sub1.example.com

    ErrorLog "var/log/sub1_error_log"
    CustomLog "var/log/sub1_access_log" common

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / http://10.10.10.10/
    ProxyPassReverse / http://10.10.10.10/
</VirtualHost>

<VirtualHost *:80>
    ServerName sub2.example.com

    ErrorLog "var/log/sub2_error_log"
    CustomLog "var/log/sub2_access_log" common

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass / http://10.20.20.20/
    ProxyPassReverse / http://10.20.20.20/
</VirtualHost>

hth Marcel

share|improve this answer
    
That's incredible! Thanks so much! =) –  Sandra Sep 20 '10 at 19:25
    
np, glad I was able to assist. –  Marcel G Sep 21 '10 at 13:39
add comment

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.