How to test VirtualHost w/o DNS?

Is there a way I can access virtualhost entries via the server's ip address and without the domain names actually pointing to the server?

What I am wanting to do it test the multiple sites before changing over the DNS stuff from the old host.

Thanks!

5 Replies

Just create entries in your HOSTS file (which should work for either Linux or Windows, I'd presume also OS X) for the domains. The server doesn't care anything about DNS, just what hostname the web browser passes in the "Host" header.

In other words, all that matters is what hostname the client thinks they're accessing.

@Guspaz:

Just create entries in your HOSTS file (which should work for either Linux or Windows, I'd presume also OS X) for the domains. The server doesn't care anything about DNS, just what hostname the web browser passes in the "Host" header.

In other words, all that matters is what hostname the client thinks they're accessing.

Thanks for the reply! Your recommendation would only work locally though, right? What about testing on Linode?

You need to have the hosts file configured on the system you're accessing the site from. It doesn't matter what the DNS configuration on the server is.

BTW, there's no need to quote someone's entire reply if you're just replying to them.

Doing /etc/hosts locally will make your browser pass along:

> Host: foo.example.com
This is the necessary magic to make virtual hosts work, without putting them in DNS just yet. Your Linode's DNS configuration shouldn't matter.

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