Reverse Proxy Test does not handle URL correctly

Hi!

EDIT: This has been solved, again s##### user error. I’m leaving the rest just for anybody having the same problem and googling their way here

The root cause for this issue is indeed a configuration problem. My configuration was the following:

        # Jenkins
        location / {
            proxy_pass http://dockerserver.domain:8088/;
            proxy_redirect     default;
            proxy_http_version 1.1;

And it should be the following (remove the slash after the url):

        # Jenkins
        location / {
            proxy_pass http://dockerserver.domain:8088;
            proxy_redirect     default;
            proxy_http_version 1.1;

When the url ends with a slash, nginx will urldecode it and the Stapler no longer parses the parameters to the test correctly. More comments on the nginx behaviour here.

Thanks a lot for all the other reporters and especially to you who took your time to answer the questions.


I’m having the same issue. Jenkins reports that the reverse proxy configuration is invalid, even though I have copied the example settings for Nginx. I have a public-facing proxy server with nginx and a jenkins/jenkins:lts-jdk17 container running on a different server, exposing port for the reverse proxy.

Technically, ReverseProxySetupMonitor/test does a 302 redirect to ReverseProxySetupMonitor/testForReverseProxySetup/ and gives the referer as a parameter. Then, the latter method checks the parameter given and the referrer are the same. So far understandable.

But when I added logging for what Stapler did, i saw the following:

Sep 23, 2023 5:54:23 AM FINE org.kohsuke.stapler.Stapler
Processing request for /administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https:/jenkins.domain/manage/
Sep 23, 2023 5:54:23 AM FINE org.kohsuke.stapler.Dispatcher
-> evaluate(<hudson.model.Hudson@73436f> :hudson.model.Hudson,"/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https:/jenkins.domain/manage")
Sep 23, 2023 5:54:23 AM FINE org.kohsuke.stapler.Dispatcher
-> evaluate(((StaplerProxy)<hudson.model.Hudson@73436f>).getTarget(),"/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/testForReverseProxySetup/https:/jenkins.domain/manage")
Sep 23, 2023 5:54:23 AM FINE org.kohsuke.stapler.Dispatcher
-> evaluate(<hudson.model.Hudson@73436f>.getAdministrativeMonitor("hudson.diagnosis.ReverseProxySetupMonitor"),"/testForReverseProxySetup/https:/jenkins.domain/manage")
Sep 23, 2023 5:54:23 AM FINE org.kohsuke.stapler.Dispatcher
-> evaluate(<hudson.diagnosis.ReverseProxySetupMonitor@56f94fa4> :hudson.diagnosis.ReverseProxySetupMonitor,"/testForReverseProxySetup/https:/jenkins.domain/manage")
Sep 23, 2023 5:54:23 AM FINE org.kohsuke.stapler.Dispatcher
-> evaluate(((StaplerProxy)<hudson.diagnosis.ReverseProxySetupMonitor@56f94fa4>).getTarget(),"/testForReverseProxySetup/https:/jenkins.domain/manage")
Sep 23, 2023 5:54:23 AM FINE org.kohsuke.stapler.Dispatcher
-> evaluate(<hudson.diagnosis.ReverseProxySetupMonitor@56f94fa4>.getTestForReverseProxySetup("https:"),"/jenkins.domain/manage")
Sep 23, 2023 5:54:23 AM WARNING hudson.diagnosis.ReverseProxySetupMonitor getTestForReverseProxySetup
https://jenkins.domain/manage vs. https:

So, Stapler, or something before Stapler, urldecodes the parameter and starts the evaluation chain after that. The end result is, that while the parameter is correct in url (except that https:// has changed to https:/), it does not get passed as a parameter as whole - the rest of the url is left out from the call as a second parameter.

Now I’m 98% sure that this is not how it should work.

2 Likes