Skip to content

Being able to edit @phpFiles matcher in php_server directive #2325

@DenuxPlays

Description

@DenuxPlays

Describe your feature request

Is your feature request related to a problem? Please describe.

We had some security issues where a user can upload a php file and execute it using our webserver.
In our old setups (with apache & php-fpm) we used to deny those executions using .htaccess files which ofcourse do not work in caddy.

Describe the solution you'd like

In the docs there is a Section (Using the php_server directive is equivalent to this configuration:) that describes how the php_server directive works.
In there you can find a @phpFiles matcher.

Would it be possible to define this matcher via an option in the php_server directive that defaults to *.php.
I imagined something like this:

php_server {
    try_files {path} index.php
    php_files "/index.php"
}

Describe alternatives you've considered

  1. Disable the upload from php files:
  • would not really achieve the same goal but block the security thread (for now)
  1. Create a matcher that serves a 403 page for every other php file
  • would work but again Frankenphp itself would still be able to execute any php files that does not match the matcher (if configured wrong)
  1. don't use the php_server directive and copy the snippet from the docs and edit it
  • would work but other users would not benefit from this approach

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions