Nginx – How to configure Nginx behind a corporate proxy

nginx

Is there an equivalent of apache's ProxyRemote directive for NginX?

So the scenario is I am behind a corporate proxy and I want to do proxy passes for various services with NginX. I would do it in Apache with the following:

ProxyPass /localStackOverflow/ https://stackoverflow.com/

ProxyPassReverse /localStackOverflow/ https://stackoverflow.com/

ProxyRemote https://stackoverflow.com/ http://(my corporate proxy IP)

I know I need the proxy_pass directive in NginX but can't find what I would use for the ProxyRemote.

Thanks

Best Answer

Not sure how @tacos response can work - possibly something I'm missing but the only way I could sort of get this to work was by rewriting the url and passing on to the corporate proxy. This is shown below:

http {
  server {
    listen 80;
    location / {
          rewrite ^(.*)$ "http://www.externalsite.com$1" break;
          proxy_pass http://corporate-proxy.mycorp.com:8080;
    }
  }
}

This works, but does rewrite the url, not sure if this is important to the original use-case..

Related Topic