Access domains via IP

I'm building a new version of a site on my Linode Debian installation and would like to set it up so that I can access my domains via IP address before actually switching the DNS over as I've been able to do on other servers - in this case, not the main domain but one of the secondary domains I set up.

I figured the first step would be to get the IP to resolve to my main domain, but I can't even seem to get that to work. Currently when I access my main IP address it delivers the default "It Works"HTML file in the /var/www folder, rather than the folder for the domain itself.

I followed the instructions on "Adding IP Addresses" (http://library.linode.com/networking/co … interfaces">http://library.linode.com/networking/configuring-static-ip-interfaces) and edited the /etc/network/interfaces file as well as the /etc/hosts but it did not seem to have any effect. Please note, I'm new to Linux so I might be misunderstanding a concept or two (ie, patience is appreciated), but I've hit a brick wall with the documentation.

3 Replies

Simplest way - add a line in format

#Your Linode's IP  Desired DNS name
111.222.333.444    www.example.tld
111.222.333.444    sub1.example.tld
111.222.333.444    other.example.tld

to the hosts file on your workstation - it will make this specific computer look for that domain at the new address, while all the stuff around the world will receive the "old" address from DNS.

It's /etc/hosts on Unixen, and %WINDIR%\system32\drivers\etc\hosts on Windows.

(Yes, witout an extension; if you edit it with Notepad or Wordpad it might add a .txt at end, which you'll have to remove afterwards!)

> As mentioned earlier, there are some clients who do not send the required data for the name-based virtual hosts to work properly. These clients will always be sent the pages from the first virtual host listed for that IP address (the primary name-based virtual host).
The same is true for clients requesting a page using the IP address (e.g., http://12.34.56.78/) - Apache will serve pages from the first virtual host only. Don't know how nginx or lighttpd handle things.

Editing your hosts files as rsk suggests is probably the easiest way to test (don't forget to change it back afterward!).

Note that if you're using IP-based virtual hosts rather than name-based, you should see this instead.

@Vance:

Don't know how nginx or lighttpd handle things.

With Lighty one can set default settings (and therefore default docroot) and override those settings for individual domains using regex based matching against Host (or url, or a few other hooks). For most advanced purposes similar to Apache virtual hosts, this is the only way.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct