Test PATH_INFO support in Caddy

This is a repo to provide some rough tests about PATH_INFO support in Caddy v2.x using containers via docker-compose.

The code here is just a proof to help the work in caddyserver/caddy#3718 by comparing how 3 different vendors (caddy, apache and nginx) manage the same set of URLs pointing to a PHP script charged to use PATH_INFO to perform some kind of routing.

Setup

PHP

PHP has been exposed via FPM using v7.4.10 w/o any supplementar extension but those provided by the official docker image.

Caddy

Caddy v2.1.1 is provided by the official docker image and it has been configured:

  1. using the standard php_fastcgi directive, which has an issue in properly managing PATH_INFO, described in caddyserver/caddy#3718
  2. using a variation of the expanded form of the php_fastcgi directive to avoid the "redirection issue"

Besides, the Caddy v2.1.1 official docker image has been used to host the binary which contains the candidate fix, directly taken from a related GH Action (https://github.com/caddyserver/caddy/actions/runs/263950314), using the standard php_fastcgi directive to show the effect of the fix.

Apache

Apache v2.4.38 is provided by the official docker image i.e. PHP runs as module w/o any PHP configuration change.

Nginx

Nginx v1.19.2 is provided by the official docker image and it has been configured to serve PHP via the PHP-FPM service.

Tests

The included PHP files are:

www/
├── file.php
├── index.php
├── lib
│   └── javascript.php
└── tests
    └── testsuite.php
  1. index.php just outputs the $_SERVER array and both file.php and lib/javascript.php include index.php, to simulate different routing files, w/ the goal of having one among the others declared as an index file
  2. testsuite.php just automates the test against a set of "interesting URLs" to evaluate the "expected vs actual" result:
    • /lib/javascript.php/1599824490/lib/requirejs/require.min.js
    • /index.php/foo
    • /index.php/foo?a=1&b=2
    • /foo
    • /foo.php/foo
    • /file.php/filename_UTF8_en+coded_それが動作するはず.png
    • /index.php/some%20%20whitespaces

Usage

To setup the 5 web server instances just fire the Compose:

$ docker-compose up -d

and then point your browser to http://:8080/tests/testsuite.php to see the result of testing the 3 vendors against a set of fixtures coded into that file.

To stop everything just issue:

$ docker-compose down -v

Notes

  1. Any change to a web server configuration requires to stop and start the Compose or just that web server container
  2. PHP code can be changed at any time without the need to restart anything
  3. The Caddy issue, when resolved, will be used to bump the interest to add Caddy "native" support into Moodle i.e. w/o the need to fake it as "Apache" via env SERVER_SOFTWARE Apache. @scara will do it via MDL-57646 (Caddy server support) 😉

Have fun!