This may sound odd, but I would like to be able to two things in the
same request using Fiddler. I'd like to map one hostname to another
(which I can do), but I need to preserve the Host header to match the
original hostname.
I have found a few different ways to remap the hostname. But no
matter which way I do it, it seems that the header sent with the
request always matches the updated hostname. This is not what I want,
and I'll explain why.
What I'm trying to do is test a Content Delivery Network staging
environment. The CDN staging environment requires a host header that
matches the hostname under which the config will run in production.
However, in order to get the browser to send requests to the staging
environment instead of production, I need to remap the hostname to the
staging hostname. However this causes the staging environment to
reject the request because the staging hostname does not match the
production hostname the CDN config is expecting.
Normally, a situation like this could be solved by the tried and true
local hosts file edit. Just place an entry in my local hosts file that
would map the production hostname to the staging environment IP
address. My problem with this solution is that we have a corporate
proxy server that cannot be bypassed, and this proxy server does
another DNS lookup on the hostname and essentially negates the IP
address entry I create in my local hosts file. So while possible,
editing the local hosts file is useless in our corporate environment.
I've found a Firefox add-on called Modify Headers that will allow me
to specify a host header with every request, and this sort of does the
trick. I can set the host header to always be the production
hostname, and then browse directly to the staging hostname (or IP) and
get the request to go through. The problem with this approach is the
many of the links in the application are not relative, and since the
hostname is not being remapped, they wind up taking me out of the
staging environment unless I edit every link in the address bar of the
browser. Setting the hostname to a fixed value for every request also
breaks web analytics and tracking pixels, and client side javascript
calls.
What I really need, is a way to conditionally remap the hostname from
production to staging, while preserving the production values in the
host header. In pseudo code, something like this:
If hostname =
production.com
then
set hostname =
staging.com
and
set host header =
production.com
endif
Is this something Fiddler can do?
Thanks very much for you time and sorry for such a long message,
Dave