I use a linux based router which has dnsmasq and iptables. On a LAN machine I have squid proxy. I want to know if requests for certain urls can be forwarded to the proxy, while other urls are allowed directly to the WAN. For example the request for www.onedomian.com should be forwarded to the proxy by the router.
You can use
iptables
to redirect the HTTP requests based on the destination IP (IP of web server) and/or based on the URL (some string) using string matching module.For example, you can use a rule to forward the requests to the proxy:
Another example using sting matching:
The normal case will be to forward the requests directly (given that there is no proxy settings in your browser). You just need to setup the default gateway and specify the needed
FORWARD
rules. The rules above assume using transparent proxying.If you want to specify a proxy settings in your browser, you can use exception list in the browser to specify the URLs/IPs that are not passed to the proxy server.
Yes, using a proxy.pac file, that you can save on your disc or on a http server and then setting it the proxy configuration of your browser.
This is an example found in internet, if you have particular needs let us know.