One external IP 2 servers
Currently there is one external IP pointing to a Window Web Server. Now wish to add a Linux web server. Wish to know if the following setup is ok :
119.xxx.xxx.xxx points to Window Web Server
119.xxx.xxx.xxx/Linux_Server points to the new additional Linux Server.
If the above scheme is ok, then how should it be done. (In terms of where the router should be placed and configured etc).
If the above scheme is unusual or not workable please suggest best practice scheme.
Hope somebody knowledgable could help ...
Solution 1:
Communication needs to be routed to two different ports if you have two different servers on the exact same external IP. e.g. 119.1.1.1:9000 for Server A and 119.1.1.1:9001 for Server B
If you don't want the end user to put 119.1.1.1:9000 and you want to have both servers on port 80 - it must be done like this: use an internal proxy that listens on port 80 and forwards incoming requests based on subdomain or domain to the correct "internal" ip of each of your two servers (or "x" number of servers, for that matter).
EXAMPLE:
ASSUME:
- 119.1.1.1:80 is the PORT 80 LISTENER
- 119.1.1.1:9000 for Server A and
- 119.1.1.1:9001 for Server B
So set it up like this:
- foo.com on port 80 (119.1.1.1:80)
- serverA.foo.com goes to port 80 (119.1.1.1:80) and will internally route request (not redirect, but internally route transparently) to 119.1.1.1:9000 based on subdomain saying "serverA"
- serverB.foo.com also goes to port 80 (119.1.1.1:80), routes transparently to 119.1.1.1:9001 based on subdomain saying "serverB"
- all other requests are handled by the router however you weant - they can be rejected and return 404 for instance (e.g. foo.com or serverXYZ.foo.com return 404 error because it does not match any definition in the proxy table).
NOTE: For the above, you actually ARE working on 119.1.1.1 - well, then the proxy table definitions should all say 127.0.0.1 for instance:
- serverA.foo.com --> 127.0.0.1:9000
- serverB.foo.com --> 127.0.0.1:9001
- default --> 127.0.0.1:9002
By routing transparently the end user does not know that the communication is routed - it is happening on the server side without end user knowing - only YOU knowing. You can do this with node-http-proxy for Node.js - you can do it with nginx - you can do with with most servers out there - look up how to internally proxy requests in the docs for your server of your choice.
If you have to use the same port you will need to use two different IP addresses e.g. 119.1.1.1:80 for Server A and 119.121.1.2:80 for Server B
Solution 2:
since you need to install a router and you do not have enough public addresses to assign one to each server, you will need to define an internal network so the two servers can talk to each other, and access the public connection.
unfortunately HTTP servers assume that redirect urls are public, so a 30x redirect would just ask the client browser to access the other host. since your linux server is only accessible inside your lan, the client would get a a url they couldn't use and a server not found.
consider using NAT, and forwarding a TCP port (or more than one if you have additional services) to the services on each internal server. you can only use each port once, but if IIS has tcp/80, you can assign apache or nginx port 81. it does mean that clients would have to enter http://example.com:81/
to access the service. you can use dns to cover that up however. you could even use that url to 301 redirect to your linux server.
once you get your router, look at http://portforward.com/ for your model of router to learn how to use NAT to forward traffic to a port.