8

I have multiple web servers behind a single firewall (SVN, Exchange, etc.). I want to be able to access all of the various servers remotely, but since they are All using the same port (the standard HTTPS), is this possible?

If I set it up so that each is listening on different ports, would it be possible to make it so that I could access each server using a different sub-domain (so svn.domain.com would point to svn, mail.domain.com would point to exchange server)? Is there perhaps a way to set up my router to forward a port differently depending on which sub-domain the client requested?

How do people normally go about this issue?

9

Personally I like using a reverse proxy in apache when serving multiple servers behind one IP address. I wrote up an article on this a few years ago.

There may be times when you need to have multiple web servers, but you have been given only one Public IP Address. The issue you will run into is that you want to have your multiple domains resolve the same IP address, but point to a different server. This is very doable with Apache. I configured a gateway server within my private cloud with an address of 192.168.1.2. I have several web servers with local addresses; 192.168.1.10 and 192.168.1.11 for example.

On my Gateway server, I install Apache and the mod_proxy files. Once this is complete, I am able to set up the virtual hosts to forward the domain.

<VirtualHost *:80>
   DocumentRoot /var/www/example.org
    ServerName *.example.org
    ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>
    ProxyPreserveHost on
    ProxyPass / http://192.168.1.10/
    ProxyPassReverse / http://192.168.1.10
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot /var/www/example.com
    ServerName *.example.com
    ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>
    ProxyPreserveHost on
    ProxyPass / http://192.168.1.11/
    ProxyPassReverse / http://192.168.1.11/
</VirtualHost>

Restart Apache and configure your router to accept incoming connections to the 192.168.1.2 local address. Though I could have pointed the DocumentRoot to the same location (i.e. /var/www), but I usually have .htaccess files for each site where I can force SSL (redirect 80 to 443 on specific domain names).

The nice thing about this route is that you can serve multiple HTTPS servers with the same IP Address. The only issue is that Internet Explorer doesn't recognize the VirtualHost port 443 or named host and you would get a certificate error. However, Safari, Firefox and Chrome all recognize each individual certificate for the domain that is being proxied.

  • This is exactly what I want to do, but since I am currently using Windows active directory server as my DNS, I was hoping to accomplish this in IIS, so that I can keep all of the gateway/authentication stuff in my network on the same server - do you know how to do this in IIS? – William Jun 3 '13 at 23:24
  • Lol, sorry, I do not. However, what version of IIS you running? – kobaltz Jun 3 '13 at 23:25
  • IIS 8 - if I wanted to figure out to do it on my own - do you have any hints at least? Keywords that I should search for? I'm sort of a n00b when it comes to web servers (I promise that I'm good at other stuff though!) – William Jun 3 '13 at 23:43
  • Internet Explorer on Windows Vista, Windows 7, Windows 8, and Windows 10 have the "Server Name Indication" feature to recognize virtual hosts. Only Internet Explorer on Windows XP and older lack this. – Damian Yerrick Nov 8 '16 at 19:16
2

Or you can use PageKite :)

See project page below:
https://pagekite.net/wiki/OpenSource/

1

You can accomplish this by setting up subdomains in your internal and external DNS. Here is a good article explaining what you need to add based on what DNS your are running. Remember, when adding entries to external DNS, it takes time to propagate.

  • This does not answer the question as it seems to be missing two key points: there are multiple servers (1) behind a firewall, (2) sharing an external IP address and TCP/UDP port. No matter which one of foo.example.com or bar.example.com the client picks, the DNS query is always going to return the same IP 203.0.113.4 either way. Then the client goes on to make its HTTP request to 203.0.113.4 with Host: bar.example.com. Who is going to put the client through so it ends up actually talking to bar? – Synoli Jan 26 '16 at 14:23
1

Kobaltz's is probably the best solution.

But if you are willing to use a non-default ports you can setup port forwarding (actually its just NAT that changes the source/destination port) of one of the apps. So you would have one of them represented as normal port 443 for https and the other at something like 8443. To browse to that other server you will need to enter https://youipaddress:8443 (or the DNS entry if you have one setup). Of course this only works if you are willing to use a different port number, but its a pretty common solution when capabilities are limited.

Specific configuration will vary greatly based on the edge device performing the NAT (your firewall or router), but generally you will translate like this:

internal IP -> External IP (possible the IP of your outside interface) standard port (443) -> selected port (eg. 8443)

Here is a good article on port-forwarding.

0

Here's the Microsoft documentation to set up a proxy server.

  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Donald Duck Aug 14 '17 at 15:23

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.