1

I am trying to setup a nginx server that forwards the incoming request to a corporate porxy (its a mcafee proxy) with a proxy header Host and the actual destination host something like proxy_set_header Host xyz.com:443.

This works perfectly fine for http requests but not for https

here is my nginx.conf (assuming no proxy auth required)

server {
        listen       80;

        location /test/ {
            proxy_pass http://my-corporate-proxy:8080/;
            proxy_set_header Host mytargetdomain.com:443;
        }

here my expectation is when i hit http://localhost:80/test/api/health the request should go to nginx and then to http://my-corporate-proxy:8080/api/health with Host header and from my proxy it should initiate a https request like https://mytargetdomain.com/api/health.

but this doesnt happening in case of https.

is there any way I can make it work ? or if I make nginx honour system proxy that should also fine.

Thanks in advance.

  • Don't use nginx for this. Use a proper forward proxy server. – Michael Hampton Aug 24 '21 at 12:40
  • thanks Michael for responding. Cant we use nginx as a proper forward proxy? Reason we are restricted to nginx is for some security reasons (restricted by our org). Adding to my original question, can nginx use system proxy ? If yes how ? I knew it doesn't by default. Please advice – V Shunmugam Aug 25 '21 at 10:55
  • Nginx is a reverse proxy; you're trying to use it as a forward proxy which it was not designed for. It is somewhat possible but you'll keep running into issues most likely. – Martin Fjordvald Aug 25 '21 at 23:35

0 Answers0