how to proxy a proxy (subrequest with corporate proxy)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to proxy a proxy (subrequest with corporate proxy)

anish10dec
Greetings,

Our custom nginx module implements a number of subrequests (REST calls to
other servers to obtain data for our business logic). Everything is working
correctly, except one customer requires a corporate HTTP web proxy for the
URL (running on a different server) that our subrequests will be hitting.
It's not clear to us how to configure a "web proxy" for a subrequest, since
the subrequest itself is already basically a "proxy" call.

Our subrequests would look like this:

location /subrequest {
    internal;
    resolver 127.0.0.1;
    proxy_pass http://rest_server/...;
}

We're aware of this kind of thing for the main request... but unclear if/how
it applies to subrequests?

http {
  upstream corporate_proxy  {
      server proxy.my.company.net:8080;
  }
  server {
    ...
    location /custom/main/request/url {
          proxy_buffering off;
          proxy_pass_header on;
          proxy_set_header Host "www.origin-server.com";
          proxy_pass http://corporate_proxy;
    }
  }
}

How would we force the subrequest to use the corporate proxy?

Thanks

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,273300,273300#msg-273300

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to proxy a proxy (subrequest with corporate proxy)

Francis Daly
On Thu, Mar 30, 2017 at 06:13:59PM -0400, CeeGeeDev wrote:

Hi there,

> It's not clear to us how to configure a "web proxy" for a subrequest, since
> the subrequest itself is already basically a "proxy" call.

Stock nginx does not speak proxied-http to a http proxy.

I suspect that the facility will only become available when someone
wants it enough to write the code, or to cause the code to be written.


If you have a config that works well-enough on your system (as in: your
proxy server is configured in a transparent-like manner, and accepts http
requests to itself and then reverse-proxies the world), then continuing
to use that config is probably appropriate.

That is: if

>     location /custom/main/request/url {
>           proxy_buffering off;
>           proxy_pass_header on;
>           proxy_set_header Host "www.origin-server.com";
>           proxy_pass http://corporate_proxy;
>     }

does everything that you want normally, then something like

> location /subrequest {
>     proxy_buffering off;
>     proxy_pass_header on;
>     proxy_set_header Host "rest_server";
>     proxy_pass http://corporate_proxy;
> }

may work for your subrequests.

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Loading...