Is there anyways I can simply say use the following proxy for all http or https traffic. Much in the same way that modern browsers typically provide the proxy functionality?
I am thinking something to the effect of :
{code}
firefoxPref network.proxy.http 192.168.22.27
firefoxPref network.proxy.http_port 80
firefoxPref network.proxy.no_proxies_on localhost, 127.0.0.1
navigate http://www.google.com
{code}
Please note the above script does not work but just provided to give an idea of what I want to achieve whether it is IE, FF or Chrome
Is this possible?
More specifically please see below in Chrome this is actually possible
https://code.google.com/p/chromium/codesearch#chromium/src/chrome/common/chrome_switches.cc&q=kHostRules&sq=package:chromium&type=cs&l=793
For example: “MAP * 127.0.0.1” → Forces all hostnames to be mapped to 127.0.0.1
“MAP *.google.com proxy” → Forces all google.com subdomains to be resolved to “proxy”.
"MAP test.com [::1]:77 → Forces “test.com” to resolve to IPv6 loopback. Will also force the port of the resulting socket address to be 77.
“MAP * baz, EXCLUDE www.google.com” → Remaps everything to “baz”, except for “www.google.com”.
These mappings apply to the endpoint host in a net::URLRequest (the TCP connect and host resolver in a direct connection, and the CONNECT in an http proxy connection, and the endpoint host in a SOCKS proxy connection)
For Chrome you can just specify whatever you want on the command-line (in the chrome tab of the advanced settings). You can either use the direct mappings or you can specify the proxy.
If you specify a proxy, you should use a PAC script that doesn’t proxy localhost traffic, otherwise the testing itself will fail (and you’ll probably need to host the pac file somewhere).
Here’s a PAC script that I’ve used before:
function FindProxyForURL(url, host) {
var lhost = host.toLowerCase();
host = lhost;
if ((host == "localhost") ||
(shExpMatch(host, "localhost.*")) ||
(host == "127.0.0.1")) {
return "DIRECT";
}
if (url.substring(0,5) == "http:") {
return "PROXY proxy.example.com:80";
}
return "DIRECT";
}