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 1 Internet IP address.

I have 2 PHYSICAL web servers.

1 Windows IIS7 hosting 3 websites. Host-header names are configured in IIS7. This works OK until I add:

1 Linux (Ubuntu lucid) Apache2 hosting 1 website. VirtualHost is configured in Apache2. I followed theses steps: http://ubuntu-tutorials.com/2008/01/09/setting-up-name-based-virtual-hosting/

The two servers seem to play "tug-of-war." Could this be just a misconfiguration, or are problems supposed to occur with this kind of setup?

share|improve this question

5 Answers 5

One possible solution is to give the external IP address to the Ubuntu system and the use it's Apache to reverse proxy for the IIS7 server.

Create a virtualhost for each of the hosts on the IIS server in for example /etc/apache2/sites-avilable/iisproxyhosts

<VirtualHost *:80>
        ServerName IIS.Domain1.TLD      
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass / http://AddressOfIIServer/
        ProxyPassReverse / http://AddressOfIIServer/
</VirtualHost>

<VirtualHost *:80>
        ServerName IIS.Domain2.TLD      
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass / http://AddressOfIIServer/
        ProxyPassReverse / http://AddressOfIIServer/
</VirtualHost>

<VirtualHost *:80>
        ServerName IIS.Domain3.TLD      
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass / http://AddressOfIIServer/
        ProxyPassReverse / http://AddressOfIIServer/
</VirtualHost>

Enable proxying

a2enmod proxy_http
a2enmod proxy

Enable the iisproxyhosts and retstart apache

a2ensite iisproxyhosts
/etc/init.d/apache2 reload
share|improve this answer
    
This is probably what I'd do, only with Varnish, rather than Apache, but same difference. –  Tom O'Connor Mar 14 '11 at 10:54

Name-based virtual hosting only works when all virtual hosts are running on the same web server instance. In this case, you will need to use NAT to get both machines on the network and either configure the NAT box to forward connections to a nonstandard port to one of the boxes, or arrange for one of the web servers to proxy for the other (name based virtual hosting would then be useful to invoke the proxy). Or just buy another IP address.

share|improve this answer
3  
For the record, what you're after here is a "reverse proxy", there are quite a lot of questions about it here –  Mark Henderson Mar 14 '11 at 3:43

Microsoft TMG Server as the firewall in front of these two servers can host multiple web URL's on one public IP address and "reverse proxy" to multiple hosts behind it using NAT. Easy solution is to get another public IP as @geekosaur said.

share|improve this answer
    
Great solution, but expensive –  Mark Henderson Mar 14 '11 at 3:42

You can forward port 80 to an Apache on Linux that would serve as reverse proxy to Both Apache (On port other than 80) and IIS.

It would send request to Apache (Linux) or IIS depending on domain name in request.

share|improve this answer

You are having a server with a public IP and apache is running on it.Now you want to host your applications on LAN and also want them to be accessible on internet the important part is these applications are still running on the machines on LAN. For this situation a Reverse Proxy is needed. Here is some explanation of such a setup

let say the websites are :

a)internal1.example.com should map to internal1.example.com
b)internal2.example.com should map to internal2.example.com
c)internal3.example.com should point to internal3 .example.com
d)internal4.example.com should point to internal4 .example.com

                           |--------------192.168.1.3 
                           |            (internal3.example.com)
                           |
                           |--------------192.168.1.4
                           |            (internal4.example.com)
  (Public IP )             |
            A-------------|
(reverse proxy server)     |
  (192.168.1.25)           |
example.com                |
                           |--------------192.168.1.1
                           |            (internal1.example.com)
                           |
                           |--------------192.168.1.2
                           |            (internal2.example.com)

I am using Ubuntu to host Apache the vhost definition in case of Debian based systems the definiton of websites is done on system A in above diagram which has public IP

/etc/apache2/sites-enabled/internal1.conf  
/etc/apache2/sites-enabled/internal2.conf  
/etc/apache2/sites-enabled/internal3.conf  
/etc/apache2/sites-enabled/internal4.conf  

The vhost definition of each of these sites will be as follows /etc/apache2/sites-enabled/internal1.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal1.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.1/
      ProxyPassReverse / http://192.168.1.1/
</VirtualHost >

/etc/apache2/sites-enabled/internal2.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal2.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.2/
      ProxyPassReverse / http://192.168.1.2/
</VirtualHost >

/etc/apache2/sites-enabled/internal3.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal3.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.3/
      ProxyPassReverse / http://192.168.1.3/
</VirtualHost >

/etc/apache2/sites-enabled/internal4.example.conf

<virtualhost *:80>

      ServerAdmin webmaster@localhost
      ServerName internal4.example.com
      ProxyRequests off
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://192.168.1.4/
      ProxyPassReverse / http://192.168.1.4/
</VirtualHost >

Note in all of the above vhost definitions I have dropped the options of Log files. So if you apply to a production server add them in each of the vhost file. Above is just to give you a clear cut example as how it can be working.

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.