Nginx reverse proxy documentation needs further update

Hi,

I ran into the same problem mentioned at Reverse Proxy Test does not handle URL correctly - #13 by juhale but the solution did not work for me. The problem is the same: nginx is encoding URL path components that it should not.

The reason that the proposed solution does not work is because I have a custom context-path. Instead of it being /jenkins, I use /builds.

Long story short, I only needed two lines to configure nginx to run Jenkins:

        proxy_pass http://localhost:305$request_uri;
        proxy_redirect http://localhost:305/builds/ $scheme://$host/builds/;

The key here is $request_uri. It instructs nginx to use the original, un-encoded URL path, so the matter of adding or omitting a slash should not be an issue.

Can someone please confim this fix (make sure that it doesn’t just work for me), and then propose changes to the documentation at Reverse proxy - Nginx?

This will probably remove the need for the follow-up section in that same page:

if ($request_uri ~* "/blue(/.*)") {
    proxy_pass http://YOUR_SERVER_IP:YOUR_JENKINS_PORT/blue$1;
    break;
}
1 Like

Hello and welcome to this community, @cowwoc. :wave:

Thanks for this solution proposal.
Please go ahead and submit the change to the documentation.
To me, that’s the best chance to get your change noticed and validated by the community.