docker-php-nginx icon indicating copy to clipboard operation
docker-php-nginx copied to clipboard

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

Open mikespub opened this issue 1 year ago • 1 comments

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 avatar Apr 25 '24 12:04 mikespub

Another example: default.conf.sample

mikespub avatar Apr 25 '24 14:04 mikespub