Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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. 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

3 Answers 3

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

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

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

 
discard

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.