'Send full URL to backend server with proxy_pass
I'd like to have Nginx act as a reverse proxy for a backend service, but the connection to the backend service must itself go through another proxy:
[nginx] -> [HTTP proxy] -> [backend service]
It does not appear that Nginx has a way to configure that the outgoing connection passes through a proxy (e.g., the http_proxy environment variable is ignored).
But it might be sufficient to:
Set the
proxy_passdestination to the HTTP proxy server address.Convince Nginx send the complete target URL to the proxy as in
GET http://backend/path/etcinstead of justGET /path/etc.
I tried:
rewrite ^/prefix/(.*) http://backend/$1 break;
proxy_pass http://proxy;
which almost works, but the behavior of rewrite is that it stops processing and issues a redirect if the replacement begins with http://. (Code here).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
