fix(nginx): custom locations take precedence over Cache Assets regex (location ^~)#5697
Open
pos-ei-don wants to merge 1 commit into
Open
Conversation
Emit custom locations as `location ^~` so a configured Custom Location (pointing at a different upstream) is not overridden by the server-level `Cache Assets` regex location, which otherwise routes its static files (.css/.js/...) to the main upstream -> 404.
|
Docker Image for build 1 is available on DockerHub: Note Ensure you backup your NPM instance before testing this image! Especially if there are database changes. Warning Changes and additions to DNS Providers require verification by at least 2 members of the community! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A proxy host with a Custom Location pointing at a different upstream (e.g.
/paperless-> a Paperless container) andCache Assetsenabled returns 404 for static files under that path (/paperless/static/app.js,.css, ...). The Custom Location's HTML/API paths work; only asset extensions break.Root cause
Cache Assetsincludes a server-level regex locationlocation ~* \.(css|js|png|...)$ { proxy_pass <main upstream>; }. In nginx, regex locations take precedence over prefix locations, so this regex beats the Custom Locationlocation {{ path }}(plain prefix) generated by_location.conf. Asset requests under custom paths are routed to the main upstream (which doesn't know them) -> 404. The UI offers no way to raise the custom location's priority.Related: #2557, #1981, #4423.
Change
Emit custom locations as
location ^~ {{ path }}.^~gives the prefix location precedence over regex locations, so the cached-asset regex no longer hijacks custom-location paths.Caveat
^~disables regex matching within that path. Users who intend a Custom Location path as a regex would be affected. If custom paths may be regex, a guarded variant (only^~for plain prefixes) would be safer — happy to adjust based on maintainer preference.Test
example-> upstream A; Custom Location/sub-> upstream B serving/sub/x.js.Cache Assets->/sub/x.js= 404 (bug)./sub/x.js= 200 from B; main-upstream assets still cached.