kris
kris

Reputation: 12571

Access IP address website as if accessed via a domain name

I've configured Apache on a web server so that different domains show different websites.

While I wait for the DNS updates that will point my domain at this servers IP address, I'd like to test if my website is running correctly.

Is there a way I can access a website via it's IP address, but do something in the client so as to tell the Apache server I've accessed it via a domain I specify?

Upvotes: 2

Views: 1270

Answers (2)

paulsm4
paulsm4

Reputation: 121649

Sure: just add a Host field with the DNS name to your HTTP header.

At the TCP/IP level, a DNS resolver translates a hostname into an IP address, permitting the client to connect to the server.

But, once the TCP/IP connection is established, the HTTP headers provide additional information to the web server. In particular, the "Host" header field provides the host and port number of the server to which the request is being sent. Apache reads this information to redirect to a virtual host.

Upvotes: 1

architjn
architjn

Reputation: 1482

It treats the config files in a top-down approach. It will default to the first vhost based upon alpahbet (if no numbers are present), or the lowest number config file.

For example:

000-default.conf
test.com.conf
site-a.com.conf
site-b.com.conf

In the above, 000-default will be the default, because it goes “numbers, then letters”.

To see which one is being used:

apache2ctl -S

So you can basically rename and check.

Upvotes: 1

Related Questions