tags:

views:

593

answers:

2

I want to be able to send an HTTP request to "admin.foo.com", but have the request go to an IP which does not map to "admin.foo.com" in DNS. I know I can edit /etc/hosts to do this, but I'd like to avoid doing that.

To explicate, normally when you browse to "http://admin.foo.com", it sends an HTTP request that looks something like this:

GET / HTTP/1.0
User-Agent: Wget/1.10.2 (well, it'd be Firefox, but you get the point)
Accept: */*
Host: admin.foo.com
Connection: Keep-Alive

...and that request is sent to admin.foo.com's IP, which (let's say) is 10.0.0.1. The "Host" header is extracted from the URL, and that header is what Apache uses to determine which virtual host to use. If I put the IP address of admin.foo.com into Firefox, it sends the request to the right server, but the Host field has the IP address in it, and then Apache doesn't know what vhost to use, and defaults to using no vhost at all, which (in its config) causes a 403/Forbidden, so I can't navigate to the new server's IP to test this.

Again, I know I can use /etc/hosts for this, but I'd like to avoid doing so, and I figure Firefox must have some sekrit way to do this ;)

A: 

I think you should go for the /etc/hosts solution -the way I understand, all the other solutions would require a larger amount of tinkering (either a plug-in to Firefox, a low-level OS solution, or setting up a proxy); which, in terms of time, would not pay off.

Silver Dragon
+1  A: 

Turns out there's already a header which lets me do exactly what I need: Modify Headers. I just add a Host header with whatever Host it is I want to pass along.

dirtside