0

So I was trying to write some logic in my nginx.conf file to disable chunked transfer encoding based on an if statement, but when I try to run it, I get the following message:

"nginx: [emerg] "chunked_transfer_encoding" directive is not allowed here in /etc/nginx/nginx.conf:64"

I assume that is because nginx doesn't allow chunked_transfer_encoding to be placed inside an if statement, but given that information, is there anyway to make this happen?

P.S.: Bellow is the example that I tried:

location / {
    set $true 1;

    if ($true) {
       chunked_transfer_encoding off;
    }
}

I also attempted to wrap the location configuration under the if and got a similar message. And I validated that the problem was not the if statement syntax by replacing the contents of the if statement with an add_header instead.

EDIT: I also attempted to use a variable to set the value of the chunked_transfer_encoding, but that simply resulted in a message telling me that the value had to either be on or off.

0 Answers0