Welcome! Log In Create A New Profile

Advanced

Setting a header inside an if block

February 05, 2014 12:31PM
I currently have:

server{
...
if ($remote_user = "") {
return 401;
}
...
}

But what I really want is:

server{
...
if ($remote_user = "") {
add_header WWW-Authenticate 'Basic realm="mydomainhere.com"';
return 401;
}
...
}

But nginx won't allow me to use the add_header directive inside an if block. How can I achieve this?
Subject Author Posted

Setting a header inside an if block

justink101 February 05, 2014 12:31PM

Re: Setting a header inside an if block

Gena Makhomed February 05, 2014 01:40PM

Re: Setting a header inside an if block

justink101 February 05, 2014 05:12PM

Re: Setting a header inside an if block

Ruslan Ermilov February 06, 2014 04:08AM

Re: Setting a header inside an if block

justink101 February 06, 2014 03:10PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 107
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready