Welcome! Log In Create A New Profile

Advanced

Re: checking headers

Robert Paprocki
May 30, 2016 02:20PM
On Sat, May 28, 2016 at 12:48 PM, Larry Martell <larry.martell@gmail.com>
wrote:

> Is there any way with nginx to check a request's headers and send back
> a 401 if the headers are not proper?
>


Yes, you can do with this via the 'map' and 'if' directives. A trivial
example:

http {
# if the "X-Foo" request header contains the phrase 'data', set
$bar to 1; otherwise, set it to 0
map $http_x_foo $bar {
default 0;
"~data" 1;
}

server {
location /t {
if ($bar) {
return 401;
}
}
}

See also http://nginx.org/en/docs/http/ngx_http_map_module.html and
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#if
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

checking headers

Larry Martell May 28, 2016 03:50PM

Re: checking headers

Robert Paprocki May 30, 2016 02:20PM

Re: checking headers

Larry Martell May 31, 2016 07:44AM

Re: checking headers

Larry Martell May 31, 2016 07:58AM

Re: checking headers

Larry Martell May 31, 2016 09:26AM

Re: checking headers

Francis Daly May 31, 2016 09:48AM

Re: checking headers

Larry Martell May 31, 2016 10:28AM

Re: checking headers

Francis Daly May 31, 2016 11:40AM

Re: checking headers

Larry Martell May 31, 2016 12:36PM

Re: checking headers

Francis Daly May 31, 2016 04:22PM

Re: checking headers

Larry Martell May 31, 2016 04:50PM

Re: checking headers

Francis Daly May 31, 2016 07:08PM

Re: checking headers

Larry Martell June 01, 2016 04:48PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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