Repository navigation
fix(backdrop): Fix nginx config for routes conflicting with directories, fixes #7495 - #7496
Merged
rfay merged 7 commits intoAug 20, 2025
Merged
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
Member
Author
|
I think this PR in general may be a failure, but this nginx-site.conf rule is probably decent for people who encounter this specific problem: |
rfay
force-pushed
the
20250731_rfay_fix_webserver_directory_conflicts
branch
from
August 1, 2025 20:04
693fcc1 to
700747a
Compare
Remove problematic webserver directives that cause 403/redirect errors when CMS routes conflict with existing directory names. ## The Issue - ddev#7495 When a CMS defines a route (like /modules) that matches an existing directory name (modules/ directory), the current webserver configurations cause issues: - nginx configurations: Return HTTP 403 Forbidden errors due to directory listing attempts - Apache configurations: Create unwanted HTTP 301 redirects to trailing slash versions This affects every CMS and framework that DDEV supports when routes conflict with directory names. ## How This PR Solves The Issue **nginx configurations (22 files updated):** - Remove $uri/ from try_files directives to prevent directory listing attempts - Change from: try_files $uri $uri/ /index.php?$query_string; - Change to: try_files $uri /index.php?$query_string; **Apache configurations (2 files updated):** - Remove directory detection and trailing slash redirect rules - Remove: RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d - Remove: RewriteRule ^(.+[^/])$ https://%{HTTP_HOST}$1/ [redirect,last] ## Manual Testing Instructions 1. Create a DDEV project with a CMS that has directory conflicts (e.g., Backdrop CMS with modules/ directory) 2. Create a page at the conflicting route (e.g., /modules) in the CMS 3. Test: curl -I https://project.ddev.site/modules 4. Expected: HTTP 200 from CMS route (not 403 Forbidden or unwanted redirects) 5. Verify file serving still works: curl -I https://project.ddev.site/files/image.png 6. Verify directory requests handled properly: curl -I https://project.ddev.site/files/ ## Automated Testing Overview This change maintains backward compatibility - existing functionality is preserved while fixing the directory conflict issue. No new tests are needed as this resolves existing problematic behavior without changing the intended functionality. ## Release/Deployment Notes This fix affects all DDEV webserver configurations but maintains security (no directory listings) while allowing proper CMS routing. The change removes web server automatic directory selection behavior, but this is acceptable for modern CMS/framework architectures that handle their own routing. 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Revert the wordpress nginx change, go back to upstream/main - Back off of expectations in TestHttpsRedirection
Remove nginx config changes from all other CMS types and keep only the Backdrop-specific fix to address directory conflict issue reported in ddev#7495. This conservative approach minimizes risk while solving the specific problem for Backdrop CMS projects. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
rfay
force-pushed
the
20250731_rfay_fix_webserver_directory_conflicts
branch
from
August 19, 2025 19:44
700747a to
409fd37
Compare
Member
Author
|
I felt like this was too large a change to be justified by one specific site's problem, so backed out everything but backdrop's usage. |
Member
Author
|
@jenlampton it would be great if you could test this with your situation. Artifacts in #7496 (comment) |
stasadev
approved these changes
Aug 20, 2025
stasadev
left a comment
Member
There was a problem hiding this comment.
I created a modules page and it worked. I also clicked on different links to confirm nothing else broke.
Looks good to me.
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.
The Issue
Fix nginx configuration for Backdrop CMS to handle routes that conflict with existing directory names, specifically the
/modulesroute vsmodules/directory.This is critical for working locally with backdropcms.org, which has those routes.
When Backdrop CMS defines a route (like
/modules) that matches an existing directory name (modules/directory), the nginx configuration causes HTTP 403 Forbidden errors due to directory listing attempts.This fix is Backdrop-only to minimize risk while addressing the specific issue reported by the Backdrop community.
How This PR Solves The Issue
nginx configuration for Backdrop CMS:
/modules,/themes,/sites) that conflict with directoriestry_files /nonexistent @rewriteto force these routes to the CMS handler instead of attempting directory access@rewritefor consistency@rewritehandler to pass query string properly for BackdropManual Testing Instructions
/modulesroute in Backdrop CMS admincurl -I https://project.ddev.site/modulescurl -I https://project.ddev.site/files/image.pngcurl -I https://project.ddev.site/files/Automated Testing Overview
This change maintains backward compatibility - existing functionality is preserved while fixing the directory conflict issue. The change is limited to Backdrop CMS configuration only, minimizing risk to other project types.
Release/Deployment Notes
🤖 Generated with Claude Code (https://claude.ai/code)