jenkins.io icon indicating copy to clipboard operation
jenkins.io copied to clipboard

nginx config for static files

Open TobiX opened this issue 4 years ago • 4 comments

The nginx reverse proxy page contains this snippet:

  location ~ "^/static/[0-9a-fA-F]{8}\/(.*)$" {
    #rewrite all static files into requests to the root
    #E.g /static/12345678/css/something.css will become /css/something.css
    rewrite "^/static/[0-9a-fA-F]{8}\/(.*)" /$1 last;
  }

But AFAIK this cannot work, since not all static artifacts are in that directory (for example, plugin artifacts). Should that be removed? Or is there another clever way to avoid hitting Jenkins for static artifacts?

Links

  • https://github.com/jenkins-infra/jenkins.io/blob/master/content/doc/book/system-administration/reverse-proxy-configuration-nginx.adoc

TobiX avatar Dec 09 '20 08:12 TobiX

There is a typo in this reexpression, the backslashes needs to be added for this regex to be valid, instead of this: /static/ into this: \/static\/ in both places

location ~ "^\/static\/[0-9a-fA-F]{8}\/(.*)$" { #rewrite all static files into requests to the root #E.g /static/12345678/css/something.css will become /css/something.css rewrite "^\/static\/[0-9a-fA-F]{8}\/(.*)" /$1 last; }

artjomsmorscakovs avatar Apr 19 '23 08:04 artjomsmorscakovs

@artjomsmorscakovs good catch!

Would you like to open a pull request to fix the regexp in this page?

https://github.com/jenkins-infra/jenkins.io/edit/master/content/doc/book/system-administration/reverse-proxy-configuration-with-jenkins/reverse-proxy-configuration-nginx.adoc

lemeurherve avatar Apr 19 '23 08:04 lemeurherve

@artjomsmorscakovs good catch!

Would you like to open a pull request to fix the regexp in this page?

https://github.com/jenkins-infra/jenkins.io/edit/master/content/doc/book/system-administration/reverse-proxy-configuration-with-jenkins/reverse-proxy-configuration-nginx.adoc

ok, done

artjomsmorscakovs avatar Apr 19 '23 08:04 artjomsmorscakovs

Even with the typo fixed, this will break many Jenkins pages since not all "static" resources can be found in the "exploded" directory. That was the whole point I wanted to address with this issue. (So it's actually a good thing the regex was broken before...)

TobiX avatar Apr 19 '23 13:04 TobiX