Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Update 2015: I never figured it out. – Colonel Panic Feb 9 '15 at 14:13

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

share|improve this answer
How do I do that? – Colonel Panic Sep 6 '13 at 8:22
there is no need for the proxy to be transparent, just setting most of applications to use it should be enough. – Braiam Sep 15 '13 at 3:15
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?" – Colonel Panic Feb 9 '15 at 14:13
I shoved "squid transparent proxy" into Google and got this back. And "squid rewrite headers" found this. – Ignacio Vazquez-Abrams Feb 9 '15 at 22:09

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.

share|improve this answer

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|improve this answer

You need your proxy to operate in "transparent" or more correctly "Intercepting" mode. Interception is being done on different OSI level with another tools, usually firewalls. The link above will share quite a handful of details to you, don't hesitate.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.