Has anyone any idea of how to setup nginx behind a corporate firewall, to reverse proxy requests to servers outside the firewall?
The reason I want to do this is I am trying to use an application that doesn't support the standard http_proxy settings by fooling it to think the resources in question are inside the firewall (i.e. reverse proxying them with nginx).
I have tried the following:
First tried proxy_pass and passing the host:
http {
upstream corporate_proxy {
server web-proxy.mycorp.com:8080;
}
server {
listen 80;
rewrite_log on;
location / {
proxy_buffering off;
proxy_pass_header on;
proxy_set_header Host "http://public-website.com";
proxy_pass http://corporate_proxy;
}
}
}
Second tried rewriting and passing the url to the corporate firewall:
http {
upstream corporate_proxy {
server web-proxy.corp.hpecorp.net:8080;
}
server {
listen 80;
rewrite_log on;
location / {
rewrite ^(.*)$ "http://public-website.com$1" break;
proxy_buffering off;
proxy_pass_header on;
proxy_pass http://corporate_proxy;
}
}
}
This approach got me initially excited, however it is actually just doing a redirect, and not properly proxying, and ultimately fails. Is there something I am missing here?
Edit: Thanks to the commenter below that spotted my mistake, I had the protocol in the Host header var - removing it solved the problem - approach #1 seems to work just fine.