Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Fiddler as a Reverse Proxy

Fiddler specifies two options for using it as a reverse proxy.

Option 1:

Fiddler can be configured so that any traffic sent to http://127.0.0.1:8888 is automatically sent to a different port on the same machine. To set this configuration:

Start REGEDIT

Create a new DWORD named ReverseProxyForPort inside HKCU\SOFTWARE\Microsoft\Fiddler2.

Set the DWORD to the local port you'd like to re-route inbound traffic to (generally port 80 for a standard HTTP server)

Restart Fiddler

Navigate your browser to http://127.0.0.1:8888

Option 2:

Alternatively, you can write a rule that does the same thing.

Say you're running a website on port 80 of a machine named WEBSERVER. You're connecting to the >website using Internet Explorer Mobile Edition on a Windows SmartPhone device for which you cannot >configure the web proxy. You want to capture the traffic from the phone and the server's response.

Start Fiddler on the WEBSERVER machine, running on the default port of 8888.

Click Tools | Fiddler Options, and ensure the "Allow remote clients to connect" checkbox is checked. Restart if needed.

Choose Rules | Customize Rules.

Inside the OnBeforeRequest handler, add a new line of code: if (oSession.host.toLowerCase() == "webserver:8888") oSession.host = "webserver:80";

On the SmartPhone, navigate to http://webserver:8888

Both options involve using Fiddler on the same machine, but what if Fiddler and the web server run on two different machines? For example, say that example.com is queried by some user and resolves to 1.2.3.4. Can I run Fiddler on 1.2.3.4 to forward traffic to 1.2.3.5 whenever example.com is queried? Assuming I use option 2 to configure Fiddler, would I set 'webserver' to example, example.com, www.example.com, or the IP address of example.com (assume www.example.com is an alias of example.com)?

like image 766
Bhubhu Hbuhdbus Avatar asked Mar 22 '12 21:03

Bhubhu Hbuhdbus


1 Answers

if (oSession.HostNameIs("subdomain.example.com")) {
    oSession.bypassGateway = true; // Prevent this request from going through an upstream proxy
    oSession["x-overrideHost"] = "128.123.133.123"; // DNS name or IP address of target server
}

Simulate the Windows HOSTS file, by pointing one Hostname to a different IP address

like image 165
easylogic Avatar answered Oct 05 '22 18:10

easylogic