Welcome! Log In Create A New Profile

Advanced

Process the backend response header

Posted by jschulz 
Process the backend response header
June 20, 2013 08:21AM
Hi,

location /api {
if ($cookie_API) {
### make a http request to the varnish backend

# check if the varnish response contains x-api-ok
if ($http_X_API_OK) {
proxy_pass http://api-aaa/;
}
}

proxy_pass http://api-bbb/;
}

what I want to do is the following:

If the incoming request has a cookie named API, then nginx sends a http request to a varnish backend.

If the varnish response header contains X-API-OK, then nginx processed a proxy request to api-aaa. If a cookie is not set or the http response header does not has X-API-OK set, then a proxy request to api-bbb is processed.

Is that possible with nginx?

Cheers
Jonny
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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