Skip to content

Conversation

@mgutt
Copy link
Contributor

@mgutt mgutt commented Dec 27, 2025

The regex pattern ~ /sub/(.*)$ matched /sub/ anywhere in the path, including file paths like /mnt/disk2/test/foo/sub/file.iso. This caused nginx to route these requests to the nchan subscriber endpoint instead of serving the files.

Changed to ~ ^/sub/(.*)$ to only match paths that start with /sub/, which is the correct behavior for the nchan websocket endpoint.

Fixes #2493

Summary by CodeRabbit

  • Bug Fixes
    • Improved URL path matching precision for subscriber endpoints to prevent unintended route matches.

✏️ Tip: You can customize this high-level summary in your review settings.

The regex pattern '~ /sub/(.*)$' matched /sub/ anywhere in the path,
including file paths like /mnt/disk2/test/foo/sub/file.iso. This caused
nginx to route these requests to the nchan subscriber endpoint instead
of serving the files.

Changed to '~ ^/sub/(.*)$' to only match paths that start with /sub/,
which is the correct behavior for the nchan websocket endpoint.

Fixes unraid#2493
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 27, 2025

Walkthrough

The nginx configuration in etc/rc.d/rc.nginx was updated to anchor the nchan_subscriber location pattern with a start-of-string anchor (^), changing it from /sub/(.*)$ to ^/sub/(.*)$. This ensures the pattern matches only paths beginning with "/sub/" and prevents unintended matching of paths containing "/sub/" in other contexts.

Changes

Cohort / File(s) Summary
Nginx location pattern fix
etc/rc.d/rc.nginx
Modified nchan_subscriber location block regex from /sub/(.*)$ to ^/sub/(.*)$, adding start-of-string anchor to prevent matching "/sub/" paths that appear in file paths within directories named "sub".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through /sub/ with glee,
With anchors in place, now downloads run free,
No more infinite waits for files tucked away,
The nchan endpoint knows its place today! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a regex pattern to prevent incorrect matching of /sub/ in file paths.
Linked Issues check ✅ Passed The change directly addresses issue #2493 by modifying the nginx regex from '~ /sub/(.)$' to '~ ^/sub/(.)$' to fix file downloads for paths containing 'sub' directories.
Out of Scope Changes check ✅ Passed The change is limited to the nchan regex pattern in nginx configuration, which is directly scoped to resolving the reported issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File manager: Download of files laying under a folder named "sub" can not be downloaded

1 participant