Rewrite undecoded URL

Hello. We are trying to use the nginx rewrite rule, without the
application
of URL decoding. The relevant portion of our test configuration is:

 location ~ ^/p/stratus.* {

    include                             conf.d/hosts.conf;



    proxy_pass                          http://localhost:8080;
    proxy_set_header Host        $host;

    # strip leading /p (note that 'break' stops processing

ngx_http_rewrite_module directives, including ‘set’)

    rewrite ^/p(.*)$

$scheme://$server_addr/?redirect_to=$scheme://$host/$1 break;
}

 location / {
    return 200 'Twas Brillig...';
}

The rewite behaves properly in stripping off the /p but writes the
decoded
url rather than leaving it untouched. We have enocded slashes (/) – %2F

within the URI. Not as parameters but in the body of the url. Nginx is
decoding these and we need to pass the url upstream intact but with the
/p
stripped.

Any help would be appreciated, as we’re out of ideas.

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

On Thu, Mar 19, 2015 at 11:52:41AM -0400, youngde811 wrote:

Hi there,

Hello. We are trying to use the nginx rewrite rule, without the application
of URL decoding. The relevant portion of our test configuration is:

I’m afraid that I am not sure what response you want nginx to give to
your incoming request.

But if you want to mangle a variable, “map” is usually a good thing
to use.

For example

map $request_uri $strip_the_slash_p {
default “”;
~^/p(?P/.*) $one;
}

and then you can later use the variable where it is set, such as

location /p/ {
return 301 $strip_the_slash_p;
}

f

Francis D. removed_email_addre[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs