Using NGINX as a forward proxy
CJ Ess
zxcvbn4038 at gmail.com
Fri Nov 18 21:54:53 UTC 2016
Thank you, very helpful! I was able to get it working with my
http://www.google.com test case. it looks like my next problem is that the
upstream is always contacted on port 80 regardless of the scheme or the
port specified in the uri. Is there a handy variable that has the correct
value (user specified or scheme default)? I looked though the vaiable
descriptions but didn't see any that looked appropriate.
On Fri, Nov 18, 2016 at 3:15 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> Hello!
>
> On Fri, Nov 18, 2016 at 02:55:13PM -0500, CJ Ess wrote:
>
> > 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?
>
> Unofficial advice is to try looking into error log, it is expected
> to contain details.
>
> In this particular configuration I see at least the following problems:
>
> - $http_host is used, but Host header won't be available in case of
> forward proxy; $host is to be used instead, it will also contain
> host from the request line.
>
> - $request_uri already includes request arguments, "$is_args$args"
> part is not needed.
>
> --
> Maxim Dounin
> http://nginx.org/
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20161118/0770c540/attachment.html>
More information about the nginx
mailing list