Incompatibility with FallbackResource and SetHandler
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start with 8.4/bookworm/apache/Dockerfile around lines 97-99 and the generated docker-php.conf containing the FilesMatch SetHandler rule. Reproduce the reported FallbackResource behavior for existing and missing .php URLs, then evaluate the proposed handler configurations. Done means PHP files still use the PHP handler while missing .php URLs reach FallbackResource without a 404.
Written by the indexing model from the issue text.
Description
I've just encountered an issue whereby our FallbackResource is applied correctly, except where the URL requested ends in .php.
For example:
- http://localhost/example.html => Uses FallbackResource
- http://localhost/example.php => Does not use FallbackResource and results in a 404
It seems that it's because the docker-php.conf configuration file sets the PHP Handler for any file which matches .php, and therefore the FallbackResource (handler) is not applied.
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
https://github.com/docker-library/php/blob/master/8.4/bookworm/apache/Dockerfile#L97-L99
This has been raised (and rejected) in the Apache Bugzilla:
https://bz.apache.org/bugzilla/show_bug.cgi?id=52403#c7
There seems to be a few possible solutions:
- Use
AddTypeinstead ofAddHandlerorSetHandler. I'm not sure if this is suggestion on the bz issue is from the Apache team, or is an observeration. I'm not sure whether this is a viable option - Wrap the
SetHandlercall in a conditional - Switch to
mod_rewrite(not generally recommended now thatFallbackResourceexists)
Re 2, the change would be something like this:
<FilesMatch \.php$>
<If "-f %{REQUEST_FILENAME}">
SetHandler application/x-httpd-php
</If>
</FilesMatch>
(Suggestion found here: https://stackoverflow.com/questions/50439963/apache-fallbackresource-configuration)
This would likely have a performance impact, but I would imagine no worse than using mod_rewrite.
I've tested the conditional SetHandler locally and it works as expected.
- Dominant language
- Dockerfile
- Stars
- 4k
- Forks
- 2k
- Avg merge
- 5d 21h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from docker-library/php
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
docker-library/php#1674 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
docker-library/php#1680 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
docker-library/php#1675 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
docker-library/php#1673 · 5 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
docker-library/php#1631 · 9 comments · 6 reactions ·
All issues in docker-library/php
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Azure/azure-functions-docker#1257 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
conda-forge/vowpalwabbit-feedstock#104 · 1 comment · 1 reaction ·
-
good-start
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
deploy.sh hardcodes --dest while components.conf advertises WITH_PROXY_CA_BUNDLE as env-overridable Openarea:proxy bug security severity:low track:open-source
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
components-web-app/docs#73 ·