使用 nginx 代理到代理

使用 nginx 代理到代理

我正在嘗試使用該proxy_pass指令將請求代理到不同的伺服器。

在下面的conf中,/api1api2被正確代理,但api3不是。

伺服器api3.server3.com運行一個 Apache 伺服器,該伺服器代理/api-alt到正確的伺服器(我無法透過 nginx 伺服器聯繫該伺服器)

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返回 HTTP/400(錯誤請求)

我想讓這個 proxy_pass 正常工作,但我很困惑。

相關內容