Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Nginx behind a corporate proxy

Tags:

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

like image 378
Simon Kenyon Shepard Avatar asked Aug 08 '12 13:08

Simon Kenyon Shepard


1 Answers

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..

like image 52
Mark D Avatar answered Nov 01 '22 03:11

Mark D