rewrite causing $ to be escaped

Sunil Shah sunil at
Tue Dec 15 00:26:33 UTC 2015


We're running Jenkins behind an Nginx reverse proxy and see issues where
Jenkins running in Tomcat returns 404 because it receives URLs that have $
encoded as %24. From the Tomcat logs: - - [15/Dec/2015:00:15:22 +0000] "POST
/%24stapler/bound/c43ae9fc-dcca-4fbe-b247-82279fa65d55/render HTTP/1.0" 404

If we access Tomcat directly, it does not return a 404 and $ is not encoded: - - [15/Dec/2015:00:16:54 +0000] "POST
/$stapler/bound/95ed7e0f-f703-458a-a456-8bf729670a4a/render HTTP/1.1" 200

When I log the $request_uri and $uri variables, it doesn't look like the $
is being encoded:
Dec 15 00:15:22 nginx[2732]: nginx: [15/Dec/2015:00:15:22
+0000] Hi Sunil! Request URI:
is now URI: /$stapler/bound/c43ae9fc-dcca-4fbe-b247-82279fa65d55/render

However, it looks like the rewrite rule in our location block is causing
the $ to be encoded. If I comment out this block or change the regex so it
doesn't match, this works.

Here's the relevant configuration block:
location ~ ^/service/jenkins/(?<path>.*) {
            rewrite ^/service/jenkins/?.*$ /$path break;

            proxy_set_header        Host $http_host;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For
            proxy_set_header        X-Forwarded-Proto $scheme;

            proxy_redirect http://$host/service/jenkins/ /service/jenkins/;
            proxy_redirect http://$host/ /service/jenkins/;

Is there a way to bypass this encoding (an equivalent to Apache's noescape
<> flag?)?

Thanks in advance,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list