"Error 413 Request Entity Too Large" when uploading images larger than 1mb. #3473

Closed
opened 2026-02-05 06:49:17 +03:00 by OVERLORD · 10 comments
Owner

Originally created by @Alpaca0x0 on GitHub (Jan 25, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Description

As title said, server return 413 Request Entity Too Large error when I'm trying to upload the images that size over 1 mb.
I don't know where the error from(PHP, Nginx or Bookstack).

What I have tried

  • PHP
    I have edited /config/php/php-local.ini, set upload_max_filesize = 100M, and post_max_size = 100M.
  • Nginx
    I have edited /config/nginx/nginx.conf, set client_max_body_size 300m and client_body_timeout 120s in http{} block.
  • Bookstack
    I have edited /app/www/.env, add FILE_UPLOAD_SIZE_LIMIT=64 and APP_DEBUG=true.

(;´༎ຶД༎ຶ`) HELP... ME... PLZ...

Exact BookStack Version

v22.11.1 (from docker image: lscr.io/linuxserver/bookstack)

Log Content

  • /app/www/storage/logs/laravel.log has nothing
  • nothing in folder /var/log/php8/
  • /var/log/nginx/error.log, only single line [notice] 501#501: signal process started

PHP Version

PHP 8.0.25

Hosting Environment

  • Ubuntu Server 22.04.1 LTS
  • Docker version 20.10.23
Originally created by @Alpaca0x0 on GitHub (Jan 25, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario ### Description As title said, server return `413 Request Entity Too Large` error when I'm trying to upload the images that size over `1 mb`. I don't know where the error from(**PHP**, **Nginx** or **Bookstack**). ### What I have tried - **PHP** I have edited `/config/php/php-local.ini`, set `upload_max_filesize = 100M`, and `post_max_size = 100M`. - **Nginx** I have edited `/config/nginx/nginx.conf`, set `client_max_body_size 300m` and `client_body_timeout 120s` in `http{}` block. - **Bookstack** I have edited `/app/www/.env`, add `FILE_UPLOAD_SIZE_LIMIT=64` and `APP_DEBUG=true`. (;´༎ຶД༎ຶ`) HELP... ME... PLZ... ### Exact BookStack Version v22.11.1 (from docker image: lscr.io/linuxserver/bookstack) ### Log Content - `/app/www/storage/logs/laravel.log` has nothing - nothing in folder `/var/log/php8/` - `/var/log/nginx/error.log`, only single line `[notice] 501#501: signal process started` ### PHP Version PHP 8.0.25 ### Hosting Environment - `Ubuntu Server` 22.04.1 LTS - `Docker` version 20.10.23
OVERLORD added the 🐕 Support label 2026-02-05 06:49:17 +03:00
Author
Owner

@liuhuanshuo commented on GitHub (Jan 25, 2023):

I recently encountered a problem similar to yours, I just added the following parameters to solve it

.env file

FILE_UPLOAD_SIZE_LIMIT=50

nginx.conf

  types_hash_max_size 2048;
  client_max_body_size 100m;
@liuhuanshuo commented on GitHub (Jan 25, 2023): I recently encountered a problem similar to yours, I just added the following parameters to solve it `.env file` ``` FILE_UPLOAD_SIZE_LIMIT=50 ``` `nginx.conf` ``` types_hash_max_size 2048; client_max_body_size 100m; ```
Author
Owner

@Alpaca0x0 commented on GitHub (Jan 25, 2023):

@liuhuanshuo I have added these parameters to the config files(including types_hash_max_size 2048 now)
and I have typed command php artisan config:clear, docker restart <container>, but still not working after restart.

@Alpaca0x0 commented on GitHub (Jan 25, 2023): @liuhuanshuo I have added these parameters to the config files(including `types_hash_max_size 2048` now) and I have typed command `php artisan config:clear`, `docker restart <container>`, but still not working after restart.
Author
Owner

@liuhuanshuo commented on GitHub (Jan 25, 2023):

@Alpaca0x0

看到你来自中国台湾,我们用中文说吧。

你是否有在修改nginx参数后执行nginx -s reload 来让配置生效?

根据我的经验,在修改.env文件的配置参数之后,是实时生效的,无需重启容器

@liuhuanshuo commented on GitHub (Jan 25, 2023): @Alpaca0x0 看到你来自中国台湾,我们用中文说吧。 你是否有在修改nginx参数后执行`nginx -s reload` 来让配置生效? 根据我的经验,在修改.env文件的配置参数之后,是实时生效的,无需重启容器
Author
Owner

@Alpaca0x0 commented on GitHub (Jan 25, 2023):

@liuhuanshuo 是的,我有在编辑完設置文件后,使用 nginx -s reloadphp artisan config:clear 重新读取新配置。
并且也会将 docker container 使用 docker restart <container> 重啟。
但仍无法解决当我上传图档大小超过 1mb 时,伺服器回应 413 的错误。

@Alpaca0x0 commented on GitHub (Jan 25, 2023): @liuhuanshuo 是的,我有在编辑完設置文件后,使用 `nginx -s reload` 及 `php artisan config:clear` 重新读取新配置。 并且也会将 docker container 使用 `docker restart <container>` 重啟。 但仍无法解决当我上传图档大小超过 1mb 时,伺服器回应 `413` 的错误。
Author
Owner

@liuhuanshuo commented on GitHub (Jan 25, 2023):

报歉,我是使用 docker-compose 进行部署的,php源码被打包在镜像里面,所以只需要修改两个配置文件。但是我是完全按照这个页面的流程进行配置的,而且生效了

如果你使用php来开发,似乎你还需要在php.ini 中添加才能使设置生效

post_max_size = 50M
upload_max_filesize = 50M

我的版本也是v22.11.1,我想这一定是一个能解决的问题!

@liuhuanshuo commented on GitHub (Jan 25, 2023): 报歉,我是使用 `docker-compose` 进行部署的,php源码被打包在镜像里面,所以只需要修改两个配置文件。但是我是完全按照[这个页面的流程进行配置的](https://www.bookstackapp.com/docs/admin/upload-config/#bookstack:~:text=PHP%20%E6%9C%89%E4%B8%A4%E4%B8%AA%E5%BD%B1%E5%93%8D%E4%B8%8A%E4%BC%A0%E9%99%90%E5%88%B6%E7%9A%84%E4%B8%BB%E8%A6%81%E5%8F%98%E9%87%8F%E3%80%82%E6%89%BE%E5%88%B0%E6%82%A8%E7%9A%84php.ini%E6%96%87%E4%BB%B6%E5%B9%B6%E6%9F%A5%E6%89%BE%E4%BB%A5%E4%B8%8B%E5%8F%98%E9%87%8F%EF%BC%9A),而且生效了 如果你使用`php`来开发,似乎你还需要在`php.ini` 中添加才能使设置生效 ``` post_max_size = 50M upload_max_filesize = 50M ``` 我的版本也是v22.11.1,我想这一定是一个能解决的问题!
Author
Owner

@Alpaca0x0 commented on GitHub (Jan 25, 2023):

@liuhuanshuo 我有依照您上述官方文档中的Changing Upload Limits进行配置,
并且在 /config/php/php-local.ini 也有写入您所提到的两项参数配置。

起初我也是采用 docker-compose.yml 进行创建作业,生成了 bookstack 及 资料库的 mariadb 容器。
后来 bookstack 因自己设置错误,因此单独删除了该容器后,便照著 linuxserver/bookstack 的文档,手动的使用 docker run 命令加上文档中的参数后重新创建该容器。

当然过程一切顺利,站点也能顺利运行,只是该问题依旧存在,即便我更改了配置档案。

@Alpaca0x0 commented on GitHub (Jan 25, 2023): @liuhuanshuo 我有依照您上述官方文档中的`Changing Upload Limits`进行配置, 并且在 `/config/php/php-local.ini` 也有写入您所提到的两项参数配置。 起初我也是采用 `docker-compose.yml` 进行创建作业,生成了 `bookstack` 及 资料库的 `mariadb` 容器。 后来 `bookstack` 因自己设置错误,因此单独删除了该容器后,便照著 [linuxserver/bookstack](https://github.com/linuxserver/docker-bookstack) 的文档,手动的使用 `docker run` 命令加上文档中的参数后重新创建该容器。 当然过程一切顺利,站点也能顺利运行,只是该问题依旧存在,即便我更改了配置档案。
Author
Owner

@liuhuanshuo commented on GitHub (Jan 25, 2023):

@Alpaca0x0

看到你提到还是使用docker run,所以还是使用docker部署。根据我的理解,docker部署就不用再处理php-local.ini类似文件了。

为了确定你的问题是否出现在nginx侧,我建议你可以在本地电脑上重新部署站点,并且仅为.env添加一行FILE_UPLOAD_SIZE_LIMIT=50,之后在127.0.0.1:6875上测试是否可以上传更大的文件。

如果在本地可以,那么就是你的nginx配置没有正确设置,你应该检查你服务器上的nginx.conf文件是否生效!

@liuhuanshuo commented on GitHub (Jan 25, 2023): @Alpaca0x0 看到你提到还是使用`docker run`,所以还是使用docker部署。根据我的理解,docker部署就不用再处理`php-local.ini`类似文件了。 为了确定你的问题是否出现在nginx侧,我建议你可以在本地电脑上重新部署站点,并且仅为`.env`添加一行`FILE_UPLOAD_SIZE_LIMIT=50`,之后在`127.0.0.1:6875`上测试是否可以上传更大的文件。 如果在本地可以,那么就是你的nginx配置没有正确设置,你应该检查你服务器上的`nginx.conf`文件是否生效!
Author
Owner

@Alpaca0x0 commented on GitHub (Jan 25, 2023):

我担心这恐怕无法准确的确认问题来自 nginx,因為当前在 docker 容器中运行不如预期,若我手动创建一个非 docker 的 bookstack,即便运行成功,则依旧可能是 nginxphpbookstack 其中一种服务所引发的问题,毕竟这三项服务皆在 docker 内外之间有所不同。

@Alpaca0x0 commented on GitHub (Jan 25, 2023): 我担心这恐怕无法准确的确认问题来自 nginx,因為当前在 docker 容器中运行不如预期,若我手动创建一个非 docker 的 bookstack,即便运行成功,则依旧可能是 `nginx`、`php`、`bookstack` 其中一种服务所引发的问题,毕竟这三项服务皆在 docker 内外之间有所不同。
Author
Owner

@Alpaca0x0 commented on GitHub (Jan 25, 2023):

我找到原因了,我很抱歉,错误出自于我伺服器上的 Nginx。我一直将目光放在 container 中的 Nginx,而忽略了我还有一个反向代理伺服器,我是个白痴 :(

I found the reason, I'm so sorry, the problem was from the another Nginx on my server(not the one on container). I forgot that I have a reverse proxy server... I'm an idiot :(

@Alpaca0x0 commented on GitHub (Jan 25, 2023): 我找到原因了,我很抱歉,错误出自于我伺服器上的 Nginx。我一直将目光放在 container 中的 Nginx,而忽略了我还有一个反向代理伺服器,我是个白痴 :( I found the reason, I'm so sorry, the problem was from the another Nginx on my server(not the one on container). I forgot that I have a reverse proxy server... I'm an idiot :(
Author
Owner

@liuhuanshuo commented on GitHub (Jan 25, 2023):

是的,当你使用了docker之后,除了需要覆盖原有样式,无需再进入容器修改相关配置文件。

@liuhuanshuo commented on GitHub (Jan 25, 2023): 是的,当你使用了docker之后,除了需要覆盖原有样式,无需再进入容器修改相关配置文件。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3473