Welcome! Log In Create A New Profile

Advanced

trouble with forward proxying

May 06, 2011 12:16PM
Hello, I've looked far and wide but couldn't find an answer to my problem.

Here's a quick description: an appserver must use the company's http proxy for outgoing http requests, but cannot be configured. So I (tried) set up nginx to act as a forward proxy, like this:

server {
listen 9099;
resolver 10.102.10.14;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://proxy.example.org:80$scheme://$http_host$request_uri;
}

error_log /cygdrive/E/data/logs/forward-proxy-nginx-error.log debug;
access_log /cygdrive/E/data/logs/forward-proxy-nginx-access.log combined buffer=32k;
}

I couldn't find any config examples where the parent proxy is used in the proxy_pass directive.

It seems like there is no other way to specify the company proxy than to add it to the proxy_pass directive.

The error message I get is this, apparently, nginx looks for a colon and takes the rest as the port number:

2011/05/06 18:01:32 [error] 2420#0: *1 invalid port in upstream "proxy.example.orghttp://www.google.com/", client: 127.0.0.1, server: , request: "GET http://www.google.com/ HTTP/1.1", host: "www.google.com"

If I change the proxy_pass directive to

proxy_pass http://proxy.example.org:80/$scheme://$http_host$request_uri;

it's the parent proxy that complains that a URL cannot start with a / character:

The following error was encountered while trying to retrieve the URL: <a href="/http://www.google.com/">/http://www.g
oogle.com/</a>

I'm at a loss how to continue. Could somebody please help? Thanks very much in advance, Jakob.
Subject Author Posted

trouble with forward proxying

jfix May 06, 2011 12:16PM

Re: trouble with forward proxying

edogawaconan May 06, 2011 12:32PM

Re: trouble with forward proxying

Igor Sysoev May 06, 2011 02:22PM

Re: trouble with forward proxying

jfix May 13, 2011 04:01PM

Re: trouble with forward proxying

Jeff Pang May 13, 2011 04:08PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 233
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready