Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41425

Refreshing page with / in job name results in 404

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • blueocean-plugin
    • None
    • BlueOcean 1.0.0-b19, Jenkins v2.32.1, Safari 10.0.3
    • pannonian, iapetus, 1.0

      When accessing a job or branch that has '/' in the name, it needs to be escaped using %2F. However, in Safari, when the page refreshes, the escapes are removed, and the URL just has a / in it. And you then get a 404 page.

      Similarly, when navigating from the regular Jenkins UI to the Blue Ocean UI in Safari, you get a 404 page and the job & branch names aren't escaped.

      Steps to reproduce:

      • create a job with / in the name
      • open the page in the Blue Ocean UI, using Safari, with the escaped URL.
      • refresh the page
      • see a 404 page.

      We get / in the job name because we use the BitBucket Branch Source Plugin (v1.9), so our jobs are in folders, and the job name ends up being <team name>/<repository name>. On top of that, we use a pattern of story/<issue-number>_<summary> for our branches, so there's another /

          [JENKINS-41425] Refreshing page with / in job name results in 404

          michaelneale mine are attached above.

          Robert Watkins added a comment - michaelneale mine are attached above.

          Michael Neale added a comment - - edited

          twasink unfortunately can't see anything wrong with that specifically: https://gist.github.com/michaelneale/886148eb67749263e935156d1fe6acab is the snippet used on that server you tried. I am not sure what would make it decode but others have seen it.

          AH:

          http://stackoverflow.com/questions/20496963/avoid-nginx-decoding-query-parameters-on-proxy-pass-equivalent-to-allowencodeds/20544409#20544409
          http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

          If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive:

          location /name/ {
          proxy_pass http://127.0.0.1/remote/;
          }
          If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI:
          location /some/path/ {
          proxy_pass http://127.0.0.1;
          }

          So to me this looks like the only difference, as you are proxying to /jenkins, it is normalising the URI for you (which is not wanted). I guess classic doesn't get hit by this (or does it?) as it always double encodes?

          Michael Neale added a comment - - edited twasink unfortunately can't see anything wrong with that specifically: https://gist.github.com/michaelneale/886148eb67749263e935156d1fe6acab is the snippet used on that server you tried. I am not sure what would make it decode but others have seen it. AH: http://stackoverflow.com/questions/20496963/avoid-nginx-decoding-query-parameters-on-proxy-pass-equivalent-to-allowencodeds/20544409#20544409 http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive: location /name/ { proxy_pass http://127.0.0.1/remote/ ; } If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI: location /some/path/ { proxy_pass http://127.0.0.1 ; } So to me this looks like the only difference, as you are proxying to /jenkins, it is normalising the URI for you (which is not wanted). I guess classic doesn't get hit by this (or does it?) as it always double encodes?

          Michael Neale added a comment - - edited

          So if you change it to something like

          location / {
              proxy_pass  http://tracking/webapp$request_uri;
          }
          

          then it should be passed verbatim, according to http://stackoverflow.com/questions/20496963/avoid-nginx-decoding-query-parameters-on-proxy-pass-equivalent-to-allowencodeds/20544409#20544409 (way too early in the morning for this).

          Or have it proxy pass without a trailing uri component and it won't normalise for you.

          Michael Neale added a comment - - edited So if you change it to something like location / { proxy_pass http: //tracking/webapp$request_uri; } then it should be passed verbatim, according to http://stackoverflow.com/questions/20496963/avoid-nginx-decoding-query-parameters-on-proxy-pass-equivalent-to-allowencodeds/20544409#20544409 (way too early in the morning for this). Or have it proxy pass without a trailing uri component and it won't normalise for you.

          Okay, so changing this, in my nginx jenkins.conf file:

          location /jenkins/ {
            proxy_pass         http://jenkins:8080/jenkins/;
            ...
          }
          

          to this:

          location /jenkins/ {
            proxy_pass         http://jenkins:8080;
            ...
          }
          

          worked.

          Hmm - going back through the history of my config file, this is what I actually had at the start of my Jenkins/Nginx config. But then I wanted to run Jenkins on a subpath so I could put another web app (Sonatype Nexus) on the same server - and that's when I screwed it up. Weird.

          Robert Watkins added a comment - Okay, so changing this, in my nginx jenkins.conf file: location /jenkins/ { proxy_pass http: //jenkins:8080/jenkins/; ... } to this: location /jenkins/ { proxy_pass http: //jenkins:8080; ... } worked. Hmm - going back through the history of my config file, this is what I actually had at the start of my Jenkins/Nginx config. But then I wanted to run Jenkins on a subpath so I could put another web app (Sonatype Nexus) on the same server - and that's when I screwed it up. Weird.

          Michael Neale added a comment -

          twasink yes I think nginx is being odd here - many people asked about this (outside of jenkins) and been burnt by it, but they keep closing it as not a bug (I guess they have their reasons) - so not your screw up by any means. Bad UX from nginx that it subtly changes behavior ... you could keep the subpath if you use $request_uri if you still wanted to do that, should work.

          Michael Neale added a comment - twasink yes I think nginx is being odd here - many people asked about this (outside of jenkins) and been burnt by it, but they keep closing it as not a bug (I guess they have their reasons) - so not your screw up by any means. Bad UX from nginx that it subtly changes behavior ... you could keep the subpath if you use $request_uri if you still wanted to do that, should work.

          Michael Neale added a comment -

          nginx config fix.

          Michael Neale added a comment - nginx config fix.

          Emmanuel Quincerot added a comment - - edited

          When should it be released?

          The ticket never appeared in the Blue Ocean release notes.

          Emmanuel Quincerot added a comment - - edited When should it be released? The ticket never appeared in the Blue Ocean release notes.

          Michael Neale added a comment -

          equincerot there is no fix on the blue ocean side - it requires a change to the config of the proxy (depends what is in use). 

          Michael Neale added a comment - equincerot there is no fix on the blue ocean side - it requires a change to the config of the proxy (depends what is in use). 

          Sorry Vivek for the assignee change. I misused JIRA shortcurts.

          Indeed, michaelneale our configuration was having a "/" at the end of the proxy_pass. It has been changed and works fine now. Thanks!

          Emmanuel Quincerot added a comment - Sorry Vivek for the assignee change. I misused JIRA shortcurts. Indeed, michaelneale our configuration was having a "/" at the end of the proxy_pass. It has been changed and works fine now. Thanks!

          Michael Neale added a comment -

          equincerot great to hear. I have put a note to configuration in the wiki/documentation but even having this ticket is handy, as google seems to find it. 

          Michael Neale added a comment - equincerot great to hear. I have put a note to configuration in the wiki/documentation but even having this ticket is handy, as google seems to find it. 

            vivek Vivek Pandey
            twasink Robert Watkins
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: