Modify http headers on system level (Linux) [close

2020-05-09 23:35发布

I want to add http header not just in firefox (using "Modify headers" plugin), but on system level. Since I can't add headers in skype's request, for example, or in IDE's, I need a single point in system to add this header. Is it possible in Linux?

P.S. "Smart" guys who want to close the question: can you put your smart comments?

3条回答
Fickle 薄情
2楼-- · 2020-05-09 23:49

You could redirect all outgoing HTTP requests to a proxy, and have that proxy (e.g. Squid) add the headers.

Redirecting all requests to a 80 port (i.e. the default HTTP port) can be done by system-wide iptables tricks (but this is disgusting).

查看更多
你好瞎i
3楼-- · 2020-05-09 23:53

i actually just ran into this issue, but there isn't a full simple answer to this question. a lot depends on which headers you want to remove. there are some standard http protocol headers which can't be removed on page renders, but to give you some answers to your general question, you should do the following:

ServerSignature Off

ServerTokens Prod

other headers can be removed in your Apache conf file, virtual host definition or your .htaccess file, assuming you're using Apache and you have mod_headers turned on:

<IfModule mod_headers.c>
Header unset HEADER_NAME
</IfModule>

just to reiterate, a lot depends on which headers you want to remove, so if Header unset doesn't work fully, then some of these headers can't be removed without modifications to your apache source or full knowledge of mod_perl to override standard headers. you can also try to use php, or your code of choice to edit headers, but you may experience some issues with that as well.

i hope this helps, again i just went through this, so i hope to help on some of the challenges and pitfalls, if i can :)

查看更多
劳资没心,怎么记你
4楼-- · 2020-05-09 23:59

Using a proxy is really the only way to do this on a system wide basis. Linux has no concept of HTTP headers... it's just there to manage the underlying sockets. Each client program, however, will need to use the proxy.

For Squid, use request_header_replace configuration directive:

request_header_replace header_name data
查看更多
登录 后发表回答