proxy_pass by the accept header?

Jonathan Leibiusky ionathan at gmail.com
Thu Jan 19 15:39:34 UTC 2012


this is a great solution!
thanks so much!

On Thu, Jan 19, 2012 at 12:22 PM, António P. P. Almeida <appa at perusio.net>wrote:

> On 19 Jan 2012 14h44 WET, ionathan at gmail.com wrote:
>
> > Hi all!  I want to proxy_pass depending on the value of the accept
> > header. I have lots of locations and I wanted to add in a single
> > place a validation that if accept header is 'text/html" it should
> > proxy_pass to some specific upstream. Else, just go ahead and try to
> > match a location.
>
> > Is that possible?
>
> Perhaps something like:
>
> # http level
>
> map $http_accept $my_upstream {
>   default misc_upstream;
>   ~text/html html_upstream;
>
> }
>
> upstream misc_upstream {
>    server 127.0.0.1:8080;
> }
>
> upstream html_upstream {
>    server 127.0.0.1:8088;
> }
>
> # server level
>
> location / {
>    #... your stuff
>    proxy_pass http://$my_upstream;
> }
>
> --- appa
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120119/bbc7c10e/attachment.html>


More information about the nginx mailing list