How to manually set upstream proxy for fiddler core?
Asked Answered
G

2

9

I'd like to be able to redirect http requests from fiddler code through upstream proxys, which I want to be able to specify at runtime.

I've looked through FiddlerApplication functions, and I don't see anything that might fit, as well as I haven't found anything matching in the documentation (except that you might specify a startup flag to use system's proxy as upstream proxy).

What is the best way to specify/change fiddler core proxy at runtime?

Ginzburg answered 11/1, 2013 at 18:18 Comment(0)
D
14

If you want to send each request to a proxy, and that proxy isn't the system's default: Before each request is sent, specify the X-OverrideGateway flag on the Session. Inside your BeforeRequest handler, add the following line:

oSession["X-OverrideGateway"] = "someProxy:1234";

-Eric

Dade answered 11/1, 2013 at 23:11 Comment(4)
in this case, how do I set proxy user name and password?Ginzburg
Fiddler does not (generally) authenticate to proxies automatically on your behalf; instead, the core application can do so. If the proxies are using HTTP BASIC authentication, you can add your own Proxy-Authorization header directly.Dade
If you did want Fiddler to respond to the auth proxy, see blogs.msdn.com/b/fiddler/archive/2011/09/04/… for the procedure.Dade
Hello I added that but I'm getting this error [Fiddler] The connection to 'blahblah.com' failed. <br />System.IO.InvalidDataException SOCKS gateway failed: Gateway returned error 0x5b-&#39;request rejected or failed&#39; I added oSession["X-OverrideGateway"] = "socks=192.168.1.12:2040"; It's a socks5 proxy.Atombomb
W
2

As EricLaw have said in his answer that you have to specify X-OverrideGateway flag on the Session, although if you want to do a basic HTTP authentication to the upstream proxy, you can set the credentials by adding the Proxy-Authorization header to the session inside your BeforeRequest handler like that

string userCredentials = string.Format("{0}:{1}", "user", "password");
string base64UserCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(userCredentials));
oSession.RequestHeaders["Proxy-Authorization"] = "Basic " + base64UserCredentials;

Here's a list of the HTTP header fields https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

Wingfield answered 4/11, 2015 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.