Hi,

Is there some way to achieve this? I want to pass requests to backend based
on cache status condition.

Thanks,
Makailol


On Wed, Mar 19, 2014 at 7:45 PM, Maxim Dounin <[email protected]> wrote:

> Hello!
>
> On Wed, Mar 19, 2014 at 03:30:03PM +0530, Makailol Charls wrote:
>
> > One more thing I would like to know, would it be possible to proxy_pass
> > request conditionally based on $upstream_cache_status ?
> >
> > For example here we set request header with proxy_set_header Cache-Status
> > $upstream_cache_status; instead we can use condition like below,
> >
> > if ($upstream_cache_status = "BYPASS") {
> >     proxy_pass http://someIP;
> > }
> >
> > if ($upstream_cache_status = "MISS") {
> >     proxy_pass http://anotherIP;
> > }
> >
> > I tried this but could not find this working. I can set request header
> for
> > backend with proxy_set_header but can not use this variable
> conditionally.
>
> That's expected, as cache status isn't known at the rewrite phase
> when "if" directives are executed.  It's not even known if a
> request will be proxied at all.
>
> --
> Maxim Dounin
> http://nginx.org/
>
> _______________________________________________
> nginx mailing list
> [email protected]
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to