TrafeX / docker-php-nginx

Docker image with PHP-FPM 8.3 & Nginx 1.24 on Alpine Linux
https://hub.docker.com/r/trafex/php-nginx
MIT License
1.33k stars 721 forks source link

Weird PSR-7 request target for current nginx default.conf with path info #175

Open mikespub opened 2 months ago

mikespub commented 2 months ago

When I'm using a PSR-7 front controller to handle requests like "/login/", the value it gets with $request->getRequestTarget() is actually "/login/?q=/login/&"

I don't know much about nginx configuration, but this may be due to the nginx default.conf combining

location / {
    try_files ... /index.php?q=$uri&$args;
}

together with

location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        //...
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
}

It's easily covered in PHP code once you know that, but this was somewhat unexpected...

mikespub commented 2 months ago

Another example: default.conf.sample