Disable automatic urlencoding with proxy_pass

Hi,

Any way to disable urlencode on nginx with proxy_pass? Following is my
config and as suggested on google I already removed the “/” URI part of
of this “proxy_pass http://127.0.0.1:8090;”

Any idea how to proceed with this?

server {
### server port and name ###
listen 10.0.0.1:443 ssl;
server_name svn.server;

    ### SSL cert files ###
    ssl_certificate      /etc/pki/tls/certs/svn.server.cert;
    ssl_certificate_key  /etc/pki/tls/private/svn.server.key;
    ssl_session_cache    shared:SSL:10m;

    location / {
            proxy_pass  http://127.0.0.1:8090;
            proxy_redirect off;

            set $fixed_destination $http_destination;
            if ( $http_destination ~* ^https(.*)$ )
            {
                set $fixed_destination http$1;
            }

            ### Set headers ####
            proxy_set_header Host $http_host:$proxy_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For

$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Destination $fixed_destination;
}
}

Thanks

lupin

Posted at Nginx Forum:

On Thu, May 09, 2013 at 05:37:26AM -0400, lupin wrote:

Hi there,

Any way to disable urlencode on nginx with proxy_pass? Following is my
config and as suggested on google I already removed the “/” URI part of
of this “proxy_pass http://127.0.0.1:8090;”

Why do you think that urlencode is or is not disabled?

When I test with a similar (but http-only) config, I see the normalised
(= decoded) url passed when I use “proxy_pass http://127.0.0.1:10080/;”,
and the original (= not-decoded) url passed when I use “proxy_pass
http://127.0.0.1:10080;”, exactly as per Module ngx_http_proxy_module.

What precisely do you do to see something other than that?

f

Francis D. [email protected]

On Thu, May 9, 2013 at 2:37 AM, lupin [email protected] wrote:

Hi,

Any way to disable urlencode on nginx with proxy_pass? Following is my
config and as suggested on google I already removed the “/” URI part of
of this “proxy_pass http://127.0.0.1:8090;”

Any idea how to proceed with this?

I think I might have ran into something similar before.

Internally Nginx has 2 ways to deal with this directive :

proxy_pass  http://127.0.0.1:8090;

Either you’ve never touched the internal uri (no internal redirects for
instance) and your outgoing uri is going to be exactly the same as the
incoming uri. Internally r->valid_unparsed_uri is set to 1.

Or your internal has been modified, and the outgoing uri used by
proxy_pass
will be re-normalized.
The re-normalization process might turn up differences between incoming
and
outgoing uri.

Another way to force Nginx to send out exactly what you want is to do
something like this :

map '' $seed_uri {
    default $request_uri;
}

proxy_pass  http://127.0.0.1:8090$seed_uri;

This way you’re forcing what comes in to be exactly what comes out, but
this comes with a price and you won’t be able to use internal
redirection
and will have to modify the content of $seed_uri manually, using if and
regexps for instance.

Hope that helps,

Matthieu.