Skip to content

2.11.8: php_fastcgi returns 404 for directory URLs ending in / (index.php not served) #8353

Closed

Description

@pppizzim

Issue Details

After upgrading from 2.11.7 to 2.11.8 (Debian package from the Cloudsmith repo, Ubuntu 24.04), every directory URL that ends in / returns 404 on a php_fastcgi site, instead of running that directory's index.php. Requests that name the .php file still work, and so does /. Rolling back to 2.11.7 fixes it.

Minimal Caddyfile:

{
	admin off
	auto_https off
}
http://localhost:8080 {
	root * /srv/www
	php_fastcgi 127.0.0.1:9000
	file_server
}

Files: /srv/www/index.php, /srv/www/surveys/index.php, /srv/www/api/help/index.php.

Request 2.11.7 2.11.8
/ 200, runs /index.php 200, runs /index.php
/surveys 308 to /surveys/ 308 to /surveys/
/surveys/ 200, runs /surveys/index.php 404, FastCGI backend never called
/surveys/?s=abc 200, runs /surveys/index.php 404
/surveys/index.php 200 200
/api/help/ 200, runs /api/help/index.php 404

So the canonical-path redirect sends /surveys to /surveys/, which then 404s. It looks related to #8326 ("a try_files / file candidate ending in / only matches a directory"): for /surveys/, the first php_fastcgi candidate {path} now matches the directory itself, the rewrite leaves the path at /surveys/, it isn't *.php, and file_server returns 404 with no index.html there. That's a guess from the behavior. I haven't read the code.

The same thing happens with a full config (php_fastcgi unix//run/php/php8.3-fpm.sock, PHP 8.3 FPM). On our REDCap site it broke public survey links (/surveys/?s=<hash>). For now we're held at 2.11.7. A workaround that worked on both versions is an explicit rewrite before php_fastcgi:

@dir_index {
	path_regexp dir ^(/(?:[^/]+/)*[^/.]+)/?$
	file {re.dir.1}/index.php
}
rewrite @dir_index {re.dir.1}/index.php?{query}

Assistance Disclosure

AI used

If AI was used, describe the extent to which it was used.

Claude (Anthropic) ran the version comparison against a minimal config and a stub FastCGI backend, and drafted this issue. I reviewed the results and the text.

Version: v2.11.8 h1:E2pv1BoZ5bJaWqFkU6QvLa21iGAX8bDzlEQG4dDQ/Vc= (repro steps: the Caddyfile and table above, then curl -i http://localhost:8080/surveys/)

Activity

  1. francislavoie commented on Nov 4, 2026

    @francislavoie
    Member
  2. dunglas commented on Nov 4, 2026

    @dunglas
    Collaborator

    Fixed by #8352 (I checked with a real project)
    Sorry about that.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions