Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Apr 27 '11 at 9:01

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

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.

share|improve this answer
    
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... –  Raviraja 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 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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.