Score:1

proxy_pass to different URLs in nginx

cn flag

I want to create a reverse proxy under one location for two different upstreams. Upstreams are so different that they have different prefixes in URL, but the rest is the same.

Non-working configuration:

    upstream foo{
        server https://foo.example.com/foo;
        server https://bar.example.net/bar backup;
    }

    server{
      ...
      location /foobar/(.+) {
         proxy_pass https://foo/$1?args
      }
   }

I know I can't use URL in 'upstream' section, and I know I can't use two servers in a proxy_pass directive, but is there any way to use nginx as 'failover balancer' for two different URLs?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.