0

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.

Askirkela
  • 131
  • 5
  • 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. – Ivan Shatsky Aug 26 '21 at 14:06
  • 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 – Askirkela Aug 26 '21 at 14:37

0 Answers0