Welcome! Log In Create A New Profile

Advanced

Re: add_headers on text/html only?

Sergey Budnevitch
July 19, 2012 11:56AM
On 18.07.2012, at 8:24, Nick Semenkovich wrote:

> I'm trying to add three headers for security to all text/html content:
>
> add_header X-Content-Type-Options 'nosniff';
> add_header X-Frame-Options 'DENY';
> add_header X-XSS-Protection '1; mode=block';
>
> I'd like to add these to a number of different sites & virtual hosts in nginx.
>
> Q: Is there an easy way to add this to multiple different hosts
> without updating every server{} block?
>
> Can I put this into an http{} section in some way (but still limit it
> to text/html)?

add_header will not add header with empty value, so

add_header X-test $test;
map $sent_http_content_type $test {
text/html 1;
}

should work.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

add_headers on text/html only?

Nick Semenkovich July 18, 2012 12:26AM

Re: add_headers on text/html only?

Sergey Budnevitch July 19, 2012 11:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 142
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready