Nginx try\u files删除客户端\u max\u body\u size选项
我无法为我的symfony应用程序设置Nginx try\u files删除客户端\u max\u body\u size选项,nginx,Nginx,我无法为我的symfony应用程序设置nginx.conf。我想设置一个路由/section/upload/,该路由允许增加客户端的大小\u max\u body\u size(~100M,标准客户端\u max\u body\u size=25M) 我在/section/upload路径上发送大于25M的文件时出错。为了避免这种情况,我必须将参数client_max_body_size=100M放在位置^/index.php(/|$)中 我认为try_文件不符合我的客户机的_max_body_
nginx.conf
。我想设置一个路由/section/upload/
,该路由允许增加客户端的大小\u max\u body\u size(~100M,标准客户端\u max\u body\u size=25M)
我在/section/upload路径上发送大于25M的文件时出错。为了避免这种情况,我必须将参数client_max_body_size=100M放在位置^/index.php(/|$)中
我认为try_文件不符合我的客户机的_max_body_大小,这样设置正常吗?try_文件指令将URI重写为
/index.php
,然后在不同的位置处理。要为client\u max\u body\u size
设置不同的值,您需要在位置/节/上传
块中处理/index.php
例如:
location / {
try_files $uri /index.php$is_args$args;
}
location /section/upload {
client_max_body_size 100M;
try_files /index.php =404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
include fastcgi_params;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
}
更改了try\u files
语句,使/index.php
显示为文件参数,而不是URI参数。大多数FastCGI指令也是必需的。有关详细信息,请参见。您的位置~^/index\.php(/|$)
块是什么样子的?您的php文件位置块可能会接管其他位置块。为了确定这一点,您可能需要增加日志记录级别,如error\u log/var/log/nginx/error.log debug
然后检查哪个位置块实际被使用。@RichardSmith我更新了我的帖子。@IVOGELOV似乎通过http->server->location/->location/section/upload->location~^/index\.php(/|$)
@IVOGELOV error debug应该显示使用了哪个位置?我没有得到任何关于使用哪个位置的信息。当我尝试用您的示例发送一个30mB文件时,只有一些http fastcgi record byte
仍然收到413错误
location / {
try_files $uri /index.php$is_args$args;
}
location /section/upload {
client_max_body_size 100M;
try_files /index.php =404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
include fastcgi_params;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
}