Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 ...

share|improve this question
    
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 –  sajawikio Nov 16 '12 at 4:28
    
If there are 2 different ports, then how an external user can access the content of the 2 different servers ? Do they have to include the port number in the URL? –  Stanley Nov 16 '12 at 4:32
    
Yes they do - but there is a way where they DON'T have to put port number, even using the same IP just on port 80 (i.e. practically without specifying the port number in the URL) - this is probably what you want - see my answer I put some more detail abut this. –  sajawikio Nov 16 '12 at 4:45

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
    
Thanks for the answer. Including a port number for the URL is ok. But how should the machine be physically connected and the port number configured ? –  Stanley Nov 16 '12 at 4:46
    
Also if the URL does not contain a port number, does it go to port 80 by default ? –  Stanley Nov 16 '12 at 4:47
    
yes. no port num --> port 80. So the proxy listener server should be on Port 80 so the end user hits it, exactly –  sajawikio Nov 16 '12 at 4:49
    
so www.foo.com goes to port 80. serverA.foo.com ALSO GOES to port 80, and it will always looklike it to the end user (which is good) but if you configure your router to check your URL's and internally proxy requests, you can get what you're trying to do, and it will still look like it's coming from the same IP (well because it is) but it may be from a different server for each subdomain or even each directory if you want, even all looking like coning from the same port 80 –  sajawikio Nov 16 '12 at 4:51

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.

share|improve this answer
    
Thanks for the answer, having to include the port number in the URL is ok. But how should the router or servers be configured in order to user the specific port number ? –  Stanley Nov 16 '12 at 4:42
    
that one is really easy, just login to your server at 119.1.1.1, start the processes or modules on your server at 119.1.1.1, and make sure to configure each of them to listen as follows: one module on 127.0.0.1:9000 and the other module on 127.0.0.1:9001 for instance, and then go back outside your server and type your external IP 119.1.1.1:9000 and 119.1.1.1:9001 and voila you have two servers on two ports there. –  sajawikio Nov 16 '12 at 4:54
    
You mean I only need to make changes to the first (old) server. But seems we need to do something in Server B too to make it listen to port 9001. Do you agree ? –  Stanley Nov 16 '12 at 4:59
    
Yes you will need to do that. So for example (assuming that the servers are both located at 119.1.1.1) point the Windows Server to 127.0.0.1:9000 and then the linux one to 127.0.0.1:9001, start them and you should be able to access them from ips 119.1.1.1:9000 and 119.1.1.1:9001 respectively –  sajawikio Nov 16 '12 at 5:01
    
Just checked that 127.0.0.0/8 is assigned as Internet host loopback address. But what do "/8" and "loopback address" mean ? –  Stanley Nov 16 '12 at 5:12

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.