How to change user agent on all http requests made from my machine with Squid intercepting proxy?

17,351

Solution 1

Install nginx as a transparent proxy. here's an example configuration stanza to show how to change user-agent:

http {
    server {
        location / {
            proxy_pass              http://$host$request_uri;
            proxy_set_header        "User-Agent" "custom agent";
            proxy_connect_timeout   60;
            proxy_send_timeout      60;
            proxy_read_timeout      60;
        }
    }
}

Please check out the document proxy_set_header for details.

Solution 2

Set up a transparent proxy that rewrites the request headers on the fly.

Solution 3

for squid3 transparent proxy write..

http_port 3127  transparent

force traffic from 80 to your port 3127

iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination Server.ip.Address : 3127

to make sure it takes that route close/block port 80
all traffic coming from lan network can't access port 80.

iptables -A INPUT -i eth0 -p tcp --dport 80 -j DROP
Share:
17,351

Related videos on Youtube

Colonel Panic
Author by

Colonel Panic

Updated on September 18, 2022

Comments

  • Colonel Panic
    Colonel Panic over 1 year

    I'd like to change the user agent on all HTTP requests made from this machine. It's easy enough to change the user agent in each browser, but other apps also make http requests. It's vital I catch them all. In particular, there's one app (Steam) that has no option to change the user agent.

    Thus, I want to run an intercepting proxy that changes the user agent on all http requests made from my computer.

    I wrote this squid.conf

    # Squid normally listens to port 3128
    http_port 3128
    http_port 3127 intercept
    
    # i don't care for caching. -Matt
    cache deny all
    
    request_header_access User-Agent deny ALL
    

    It works when I point browsers at it. But how can I get Squid to intercept all http requests made by my machine? I don't understand how to make it capture stuff. Iptables? Firewalld?

  • Colonel Panic
    Colonel Panic over 10 years
    How do I do that?
  • Ludwig Schulze
    Ludwig Schulze over 10 years
    there is no need for the proxy to be transparent, just setting most of applications to use it should be enough.
  • Colonel Panic
    Colonel Panic over 9 years
    Hi. "Set up a transparent proxy that rewrites the request headers on the fly" isn't a useful answer when the question was "How do I set up a transparent proxy that rewrites the request headers on the fly?"
  • Ignacio Vazquez-Abrams
    Ignacio Vazquez-Abrams over 9 years
    I shoved "squid transparent proxy" into Google and got this back. And "squid rewrite headers" found this.