H
H
huko2016-07-19 20:04:37
Nginx
huko, 2016-07-19 20:04:37

Is it possible to know the size of the backend response?

Hi!
There is a working nginx as a proxy, is it possible to do something like this:

if ($content_length == '11088')
    { return 404; }

those. if the proxy_pass returned a response of 11088 bytes to the incoming request, then we will instead give the client a 404.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2016-07-19
@GhOsT_MZ

There is an upstream module that stores the size of the response in a variable, as well as a bunch of other useful information.
nginx.org/ru/docs/http/ngx_http_upstream_module.html

M
Mikhail Osher, 2016-07-19
@miraage

As far as I know, this can only be added to Lua as an "add-on".)

C
Cool Admin, 2016-07-19
@ifaustrue

Something tells me that you have measured the size of the page with an error coming from the backend and are diligently trying to return nginx's 404 in this case.
IMHO a rake and a crutch. Give a normal warning from the backend side and replace it on the nginx side with the one you need. It's very easy to google.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question