Rewrite undecoded URL

youngde811 nginx-forum at nginx.us
Thu Mar 19 15:52:41 UTC 2015


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



More information about the nginx mailing list