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.

When I'm setting up VirtualHosts (this is my first time doing this) on my Rackspace cloud does the URL in my browser have to be the name for it to work correctly? What I mean is, if I set my local host file on OS X to my current development server will it still work, or does the DNS actually have to point to the development server?

Does this make sense? I set up my server for the first time this week, so I could be totally off-base here.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The DNS is irrelevant and a hosts entry will be fine. Some detail as to why this is:

When your browser sends a web request it sends headers along with it. One of these headers is the "Host" header. If I try to hit your server by IP, a Host header will be omitted (or will contain the IP) and will not match your Name-Based VirtualHost declaration. Apache uses this Host header to decide what pages to serve when multiple sites are hosted on the same IP address.

The hosts method of forcing a browser to send a Host header that does not match (or even look up) DNS is a typical way to do testing and development environments.

share|improve this answer
    
Good! Just a sidenote: At work the host-force thing doesn't work, but at home it does. Any idea why it would work on one network and not the other? –  Kevin Brown Jun 8 '11 at 14:14
    
You're using a proxy at work, most likely. When you send a request to a proxy it gets a URL (like http://www.example.com/) to retrieve on your behalf. It uses it's own hostname resolution to decide where this needs to go. –  Kyle Smith Jun 8 '11 at 14:15
    
Well, that's just disappointing. Thanks! –  Kevin Brown Jun 8 '11 at 14:49

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.