Score:0

Proxying to a proxy with nginx

fr flag

I'm trying to use the proxy_pass directive to proxy requests to different servers.

In the following conf, /api1 and api2 are proxied correctly but api3 is not.

The server api3.server3.com runs an Apache server that proxies /api-alt to the correct server (which I cannot contact via the nginx server)

server {
  location /api1 {
   proxy_pass https://api1.server1.com;
  }
  location /api2 {
   proxy_pass https://api2.server2.com;
  }
  location /api3/ {
   # This one breaks
   # api3.server3.com can proxy/rewrites '/api-alt' to another server
   proxy_pass https://api3.server3.com/api-alt;
  }
}

myserver.com/api3/thing returns a HTTP/400 (bad request)

I'd like to have this proxy_pass working but I'm stumped.

Ivan Shatsky avatar
gr flag
Read [this](https://stackoverflow.com/a/53650827/7121513) answer. Note that your configuration makes `/api3/some/path` request to be proxied to `api3.server3.com` server as `/api-altsome/path` while requests started with `/api1` or `/api2` proxied as-is.
Askirkela avatar
fr flag
Thanks for the link. I just tried with `location /api3` and `proxy_pass http://api3.server3.com/api-alt` with combinations of "/" and no "/", even a rewrite rule... still no luck. I'll keep searching
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.