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 LINODE 512 account (Ubuntu 10.04 LTS) where I have got 1 IP. Using /etc/apache2/sites-available (enabled) I have hosted 4 websites, which is working very well.

But the IP address I have got gets associated with the latest website I create in my account using DNS manager. That means when I type IP address in browser it opens the latest added website only.

Now how to change that association so that it can open any website from my account I want?

share|improve this question
add comment

1 Answer

This is fundamentally not possible. This has nothing to do with DNS — it has everything to do with Apache VirtualHosts and the "Host" HTTP header.

Apache distinguishes the VirtualHost you are trying to access by the "Host" header sent in HTTP. See this site for an example.

When you are accessing your web server via the IP address, the "Host" header simply contains the IP address — i.e. not the DNS name of your hosted domains. This means Apache can't tell which site you want, and serves the first one it knows about. (Most likely you'll find it is the one that appears first in your configuration, alphabetically.)

Have a think about it. If you browse to your Linode's IP (without using a DNS name), how does Apache know which VirtualHost you meant to browse to, when you haven't actually told it thus?

You may be able to work around it by putting a "ServerAlias my_linode_ip" stanza in your VirtualHost config, but this only works for one site at a time. (i.e. you need to change the config to change where the direct IP points.)

share|improve this answer
add comment

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.