Using NGINX as a forward proxy

CJ Ess zxcvbn4038 at gmail.com
Fri Nov 18 19:55:13 UTC 2016


I know its not encouraged but I am trying to use Nginx (specifically
openresty/1.11.2.1 which is based on Nginx 1.11.2) as a forward proxy.

I did a quick setup based on all the examples I found in Google and tried
"GET http://www.google.com/" as an example and found:

This does work:

  location / {
    resolver 127.0.0.1;
    proxy_pass $scheme://www.google.com$request_uri$is_args$args;
  }

This does not:

  location / {
    resolver 127.0.0.1;
    proxy_pass $scheme://$http_host$request_uri$is_args$args;
  }

In the latter example it seems that using the $http_host variable is
causing the problem - there is a hang for a few seconds then a 502 error is
delivered.

Is there any unofficial advice?

I also see this module:
https://github.com/chobits/ngx_http_proxy_connect_module

And I really don't want to change nginx core and am concerned it'll stop
being developed after being merged with tengine, but it looks like a
possible solution - anyone have success with it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20161118/d54f7165/attachment.html>


More information about the nginx mailing list