Heroku Nginx HTTP 413 实体太大

Heroku Nginx HTTP 413 entity too large

我在上传 4MB 文件时收到 错误 413。我已经在 public/ 文件夹中创建了一个 .user.ini 文件。最多允许 10 MB 文件

所以我在 nginx.conf 上使用了 client_max_body_size 但我仍然得到 413。

location / {
    index index.php;
    try_files $uri $uri/ /index.php?$query_string;
    client_max_body_size 10M;
}

那个配置是​​因为我用的是Laravel 5.

这是我的Procfile

web: vendor/bin/heroku-php-nginx -C nginx.conf public/

我是不是做错了什么?

可能有点晚了,但为了解决这个问题,请将您的 client_max_body_size 10M; 移到位置部分之外。像这样:

client_max_body_size 10M;

location / {
    index index.php;
    try_files $uri $uri/ /index.php?$query_string;
}

有关 heroku 如何包含此文件的参考,请参阅 https://github.com/heroku/heroku-buildpack-php/blob/beta/conf/nginx/heroku.conf.php#L35