2

I have a centOS machine with multiple public IPs. We are already running one web application.

I now need to host one more web application on that machine by using one of the public IP addresses that is available for that machine.

In clear words, the IP addresses of that machine are x.x.x.226, x.x.x.227, x.x.x.228, x.x.x.229 and x.x.x.230. I want to use one of those addresses for the second web application.

Can any one help me out how to do this?

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109

2 Answers2

1

Part of the HTTP/1.1 protocol is to send the host name as part of the request -- the web server can then choose to handle requests differently, based on that information to host many websites on a single IP address.

Rowland Shaw
  • 494
  • 1
  • 9
  • 19
  • Thanks for reply, Can u please give me any reference which contains step by step process so that i can do it in simple way... –  Apr 26 '11 at 10:52
  • @Raviraja Not without more information -- if this using a webserver written by "somebody else", then you may want to say what server you're using, and head over to the sister site for webmasters at http://webmasters.stackexchange.com/. If this is something you're writing, then you may want to specify the language you're writing in, and share some of your code. – Rowland Shaw Apr 26 '11 at 11:29
0

As r.shaw mentions, you can indeed serve many different websites based upon the domain name in each request header. Here's a nice explanation and contrast between name-based and IP-based virtual hosting from apache:

http://httpd.apache.org/docs/2.0/vhosts/name-based.html

Note that if you plan to use SSL for each of your websites then you may indeed need to setup different IP-based virtual hosts. In this scenario, you'll need to setup an alias on your network adapter to handle one of the new additional public IP addresses. See 13.2.4. Alias and Clone Files, in the centos documentation:

http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-networkscripts-interfaces.html

Then you'll need to setup Apache (or whatever web-server you are using) to listen for requests on the new public IP address. Take a look through your web-server's documentation on how to do this. For apache, read:

http://httpd.apache.org/docs/2.0/vhosts/ip-based.html

Hope that helps.