我有这样的nginx配置
location /file.php
{
add_header X-Test Passed always;
allow all;
}
location ~ \.php$
{
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
limit_req zone=web burst=2;
}
但是当我尝试访问服务器上的/file.php时,“ X-Test”标头不存在,因此,我猜位置/file.php不会触发,当我将配置更改为
location ^~ /file.php
{
add_header X-Test Passed always;
allow all;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
location ~ \.php$
{
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
limit_req zone=web burst=2;
}
所有功能均按预期工作,但是fastcgi params代码行增加了一倍,所以我认为我做错了事