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 2 web Debian servers, a frontend accepting request from port 80 and a backend via proxy from the frontend.

What I want to do is have a many different URLs going the backend server with virtual hosts.

Here is the frontend Apache setting

<VirtualHost *:80>
    ServerName dev.example.com
    ProxyPass / http://192.168.144.100:80/
    ProxyPassReverse / http://192.168.144.100:80/
</VirtualHost>

<VirtualHost *:80>
    ServerName sandbox.example.com
    ProxyPass / http://192.168.144.100:80/
    ProxyPassReverse / http://192.168.144.100:80/
</VirtualHost>

And here is the backend Apache setting

 <VirtualHost *:80>
                ServerAdmin webmaster@localhost

                DocumentRoot /var/www/
                <Directory />
                        Options FollowSymLinks
                        AllowOverride None
                </Directory>
                <Directory /var/www/>
                        Options Indexes FollowSymLinks MultiViews
                        AllowOverride None
                        Order allow,deny
                        allow from all
                </Directory>
    </VirtualHost>
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost

            ServerName dev.example.com

            DocumentRoot /var/www/example.com/dev/
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/example.com/dev/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
    </VirtualHost>

   <VirtualHost *:80>
            ServerAdmin webmaster@localhost

            ServerName sandbox.example.com

            DocumentRoot /var/www/example.com/sandbox/
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/example.com/sandbox/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
    </VirtualHost>

When I go to dev.example.com or sandbox.example.com, it takes me to the default /var/www files.

Basically, I want the ability to run multiple virtual hosts on the backend server.

Thanks for your help.

share|improve this question
    
If I understand You well - just add all domains you want to support in your frontend server (a.example.org, b.example.org, c.example.org etc etc) and then on backend, you should receive specific domain (a, b, c etc.) and make it point to specific Documentroot. Is that what you want to achieve ? –  wojciechz Jan 29 '13 at 1:27
    
That's exactly what I want to do and I did just that above. In the frontend I have dev.example.com and sandbox.example.com proxying to the same IP 192.168.144.100:80. On the backend I have a virtual host setup for dev.example.com and sandbox.example.com with their own documentroot. But going to dev or sandbox always takes me to the default virtualhost. –  tdbui22 Jan 29 '13 at 1:37

1 Answer 1

up vote 0 down vote accepted

How about modifying your front end settings like this? And you don't need virtual host settings in backend.

<VirtualHost *:80>
    ServerName dev.example.com
    ProxyPass / http://192.168.144.100:80/
    ProxyPassReverse / http://192.168.144.100:80/
</VirtualHost>

<VirtualHost *:80>
    ServerName sandbox.example.com
    ProxyPass / http://192.168.144.100:80/example.com/dev/
    ProxyPassReverse / http://192.168.144.100:80/example.com/dev/
</VirtualHost>
share|improve this answer
    
Small correction on the directories but I get your point. Worked perfectly. Thank you. –  tdbui22 Jan 29 '13 at 3:04
    
You're welcome. –  Naoyuki Yamada Jan 29 '13 at 4:48

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.