Welcome! Log In Create A New Profile

Advanced

Re: allow traffic through with a certain header value

Francis Daly
June 20, 2018 11:16AM
On Tue, Jun 19, 2018 at 03:34:13PM -0400, vchhabra@medallia.com wrote:

Hi there,

> I'm trying the "if" statement below in my
> nginx app config file, but doesn't seem to quite work. It just gives a
> 403 for every request.

> location / {
> if ($http_headerkey != "headervalue") {
> return 403; }

It seems to work for me:

server {
listen 8000;
location / {
if ($http_headerkey != "headervalue") { return 403; }
return 404;
}
}

And then:

$ curl -I -H HeaderKey:headervalue http://127.0.0.1:8000/x
HTTP/1.1 404 Not Found

$ curl -I -H HeaderKey:somethingelse http://127.0.0.1:8000/x
HTTP/1.1 403 Forbidden

$ curl -I http://127.0.0.1:8000/x
HTTP/1.1 403 Forbidden

I get 403 if the key does not have the value, and I get the here-expected 404
if the key does have the value.

What do you get if you try that test?

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

allow traffic through with a certain header value

vchhabra@medallia.com June 19, 2018 03:34PM

Re: allow traffic through with a certain header value

Francis Daly June 20, 2018 11:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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