Welcome! Log In Create A New Profile

Advanced

Use if condition with $upstream_http_myheader

Posted by knasucre22 
Use if condition with $upstream_http_myheader
October 07, 2015 05:38AM
Hi Everybody,

First, I hope the question has never been asked ...

I am using NGinx as a reverse proxy and load balancing with upstream.
This is working perfectly, BUT I have to send a return code "404" when a specific header is returned from proxy.

I tried this in my server section :

<code>
location / {
proxy_pass http://myupstream;

if ( $upstream_http_myheader ) {
return 404;
}
}
</code>

This config doesn't work, i'm sure the header is valid because i receive it on client side and the "add_header testheader $upstream_http_myheader" in location section works fine also.

I think the if statement is made before the proxy_pass, but i hope i'm wrong.

Does anybody have a solution for me ?

Best regards,
Ben.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 198
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready