Welcome! Log In Create A New Profile

Advanced

Matching & Acting upon Headers received from Upstream with proxy_pass

Alec Muffett
January 31, 2019 04:08PM
Hello All!

I'm running a reverse proxy and I want to trap when upstream is sending me:

Content-Encoding: gzip

....and on those occasions return (probably) 406 downstream to the client;
the reason for this is that I am always using:

proxy_set_header Accept-Encoding "identity";

....so the upstream should *never* send me gzip/etc; but sometimes it does
so because of errors with CDN configuration and "Vary:" headers, and that
kind of thing. I would like to make the situation more obvious and easier
to detect.

I have been trying solutions like:

if ( $upstream_http_content_encoding ~ /gzip/ ) { return 406; }

and:

map $upstream_http_content_encoding $badness {
br 1;
compress 1;
deflate 1;
gzip 1;
identity 0;
default 0;
}
...
server { ...
if ($badness) { return 406; }

....but nothing is working like I had hoped, I suspect because I do not know
if/where to place the if-statement such that the
upstream_http_content_encoding is both set and valid during an appropriate
processing phase.

The most annoying thing is that I can see that the
upstream_http_content_encoding variable is set to "gzip", because if I do:

more_set_headers "Foo: /$upstream_http_content_encoding/";

....then I can see the "Foo: /gzip/" value on the client; but that does not
help me do what I want.

Can anyone suggest a route forward, please?

-a

--
http://dropsafe.crypticide.com/aboutalecm
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Matching & Acting upon Headers received from Upstream with proxy_pass

Alec Muffett January 31, 2019 04:08PM

Re: Matching & Acting upon Headers received from Upstream with proxy_pass

Maxim Dounin February 01, 2019 08:32AM

Re: Matching & Acting upon Headers received from Upstream with proxy_pass

Alec Muffett February 01, 2019 09:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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