Forum Discussion

pepito's avatar
pepito
Icon for Altocumulus rankAltocumulus
Oct 28, 2022

How to tell nginx to use a forward proxy to reach a specific destination

Hello. I accidentally closed my previous post, so I recreate this discussion because of the following problem I'm encountering. Here is the situation : I have multiple servers which are in a secu...
  • Kevin_Davies's avatar
    Kevin_Davies
    Nov 09, 2022

    Seems I have also made a mistake. In setting a proxy setting for git it treats the NGINX as a forward proxy. The issue with this is NGINX is a reverse proxy. In effect it acts as an endpoint for the forward proxy you are trying to reach.

    The error is due to NGINX  trying to interpret a forward proxy request. So I figure we need to tell it to not do any processing on the traffic and we do that with the stream command which passes the TCP stream directly to the destination.

    stream {
        upstream web_server {
            # Our web server, listening for SSL traffic
            # Note the web server will expect traffic
            # at this xip.io "domain", just for our
            # example here
            server PROXYIP:PROXYPORT;
        }
    
        server {
            listen 443;
            proxy_pass web_server;
        }
    }

    The issue with this is it intercepts ALL traffic on 443. If you dont want that then have it listen on a different port and adjust the .gitconfig to specify its proxy on the new port. You cannot tell it to match a name because at the TCP layer there is no server name.