Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

Process the backend response header

$
0
0
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

Viewing all articles
Browse latest Browse all 53287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>