I have a network setup as illustrated below. A
Windows Server 2012 R2 box with a public IP, with multiple
CentOS 7 web servers behind it. Each
CentOS box is a web server for multiple sites. The CentOS boxes are running
Apache 2.4 and
The DNS entries for all the sites point to the public IP of
Win Server (
My question is: How do I most efficiently serve the sites from the
CentOS boxes, through to end users?
I've been looking at
IIS reverse proxies. Here's my current (super-clunky) solution:
Win Servergets a request for
- The URL is re-written to
$_SERVERvariable to feed PHP the correct URL (
Win Serverhosts file says
com.foo.web1goes to the IP of
Web1has a vhost for
com.foo.web1which then serves all the stuff for
This works but it feels like a horrible hack. Ideally, I'd like to avoid rewriting URLs. I just want to say
foo.com? Send that request to
thing.com? send that to
192.168.1.3. That sounds just like DNS to me, but obviously I can't just tell the user to go to some internal IP. Maybe I actually need a forward proxy? I can't just forward port
80 because of the need to split requests between multiple servers.
I feel like this problem must have been solved before, but I can't figure it out. (I'm really a developer, not a sys-admin). Help would be much appreciated!
I dumped Win Server for Linux and used HAProxy
To save anyone who finds this from reading through all the comments, I ended up dumping Windows Server and using Linux with HAProxy. HAProxy is able to forward the requests without re-writing the URLs.
I haven't yet found a good solution for Windows, but I think this might be acceptable:
Re-write all URLs by adding a port, so:
- foo.com -> foo.com:8081
- bar.com -> bar.com:8081
- thing.com -> thing.com:8082
- stuff.com -> stuff.com:8082
Then, on the Windows Server:
- Forward port 8081 to port 80 on Web1
- Forward port 8082 to port 80 and Web2
This is untested.