This tool just gets better for me with every little bit more I learn about it. I use it as a proxy server for my VM’s to keep them of the main network, but have internet access. I use it for speed tests, I use it for dynamic debugging of javascript of sites I have no access too.  It’s wonders do not cease.

Yesterday I had an problem with a Host Named Site Collection, or rather it appears that one of the servers appeared to be slow.  But being a HNSC no AAM’s were created for it and with four front ends to test how the hell do you hit each one sseperately.

Chap running the servers was kind enough to give me the IP addresses and of course I can then edit the hosts file and test each one from the main address.

Well that sucks.

Enter Fiddler, did I say how much I love fiddler ?

In fiddler is a rules file,   CTRL-R will get you there. In that we can do marvelous things, in this case I wanted to handle my HNSC problem by having 4 separate urls I could hit and test each server in a load test script.

My host was something like

http://hnsc.binaryjam.com

and I wanted to hit

http://hnsc1.binaryjam.com

http://hnsc2.binaryjam.com

http://hnsc3.binaryjam.com

http://hnsc4.binaryjam.com

 

Here’s how to do it in fiddler.  Edit the rules file and find the function OnBeforeRequest, its all javascript dontcha know.

Add this bit of code at the bottom of the function

if (oSession.hostname == "hnsc1.binaryjam.com") {
	oSession.hostname = "hnsc.binaryjam.com";
	oSession["x-overrideHost"] = "192.168.1.10"; // <– Server IP here!
}
if (oSession.hostname == "hnsc2.binaryjam.com") {
	oSession.hostname = "hnsc.binaryjam.com";
	oSession["x-overrideHost"] = "192.168.1.11"; // <– Server IP here!
} 
if (oSession.hostname == "hnsc3.binaryjam.com") {
	oSession.hostname = "hnsc.binaryjam.com";
	oSession["x-overrideHost"] = "192.168.1.12"; // <– Server IP here!
} 
if (oSession.hostname == "hnsc4.binaryjam.com") {
	oSession.hostname = "hnsc.binaryjam.com";
	oSession["x-overrideHost"] = "192.168.1.13"; // <– Server IP here!
}

Save it and do a test.

I even ran WireShark to see what was actually happening on the network stack, and it works, it was routing requests for specific servers to each individual server, and because we set the hostname to what it should be any code JS or server using the server name works fine too.

Makes me really want to crack open the fiddler manual and find out what other voodoo I can do.

Advertisements