Welcome! Log In Create A New Profile

Advanced

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

Valentin V. Bartenev
February 18, 2015 12:14PM
On Wednesday 18 February 2015 17:57:13 Daniël Mostertman wrote:
[..]
> What am I doing wrong, if anything? And if I can avoid using "if" like
> that, I'd obviously prefer that.
>

You can avoid it by using the map directive and a variable
as the add_header value.

Like this:

map $http_user_agent $csp {
~MSIE "";
default "
default-src 'self' https://*.example.nl https://*.example.net;
connect-src 'self' https://*.example.nl https://*.example.net;
font-src 'self' data: https://*.example.nl https://*.example.net;
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.example..nl https://*.example.net;
style-src 'self' 'unsafe-inline';
img-src 'self' data: https://*.example.nl https://*.example.net;
frame-src 'self';
object-src 'self' 'unsafe-inline';
";
}

add_header Content-Security-Policy $csp;

--

wbr, Valentin V. Bartenev

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

'add_header' no longer allowed inside 'if', even though document says it is?

Daniël Mostertman February 18, 2015 11:58AM

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

Daniël Mostertman February 18, 2015 12:04PM

Re: 'add_header' no longer allowed inside 'if', even though document says it is?

Valentin V. Bartenev February 18, 2015 12:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 236
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