如何增加 nginx.conf 中的 client_max_body_size? (How do you increase the client_max_body_size in nginx.conf?)


問題描述

如何增加 nginx.conf 中的 client_max_body_size? (How do you increase the client_max_body_size in nginx.conf?)

我在本地 ddev 實例中上傳大文件時收到“413 Request Entity Too Large”錯誤,特別是使用備份和遷移從大型數據庫文件恢復時。

我正在使用 ddev 1.5.1、PHP 7.1、nginx 1.15.3 和 Drupal 7.60。我試過提供一個自定義的 nginx 配置,就像它在文檔中所說的那樣,但我試過的都沒有奏效。通過谷歌搜索,我認為問題在於 client_max_body_size 太低,但我試圖將該值加倍,但沒有任何效果。我複制了 d7 配置並添加到 client_max_body_size 行並重新啟動項目,但仍然出現錯誤。


參考解法

方法 1:

First, for this issue you really don't want to be using backup_migrate for a restore, especially for a 100MB upload, which is way huge. ddev import‑db happily accepts your backup_migrate *.mysql.gz file, and is ever‑so‑much faster and doesn't require custom config. ddev import‑db ‑‑src=/path/to/my‑backup‑migrate.mysql.gz

But to do it the way you're trying to do you have to both override nginx‑site.conf AND php.

In your .ddev/nginx‑site.conf in the "server" section, add client_max_body_size 1000M; if you want to bump it to 1GB. (See nginx custom config in docs.

In .ddev/php/bigpost.ini (name is arbitrary, see docs), you'll want:

post_max_size = 1000M
upload_max_filesize = 1000M

Then ddev rm and ddev start and you should see the upload size improved.

方法 2:

I ran into the same issue today when trying to debug some long running TUS file uploads. Apparently the problem is not necessarily with the ddev web container but with the nginx ddev‑router container. Here the request size is also limited to 100m (client_max_body_size 100m).

You can temporarily bypass this issue in by taking following steps: ‑ ssh into ddev‑router container ‑ edit /app/nginx.tmpl and set a higher client max_body_size ‑ restart router container

This works until you remove all ddev containers (or remove the last active ddev project).

(by Jake IneichenrfayRobert Lang)

參考文件

  1. How do you increase the client_max_body_size in nginx.conf? (CC BY‑SA 2.5/3.0/4.0)

#drupal-7 #ddev #nginx






相關問題

將 drupal 7 網站從服務器移動到本地主機的問題 (Issue in moving a drupal 7 website from server to localhost)

是否可以在 Drupal 中的公開過濾器上實現條件選擇? (Is it possible to implement Conditional Select on exposed filters in Drupal?)

Drupal 7 - 創建依賴的自動完成表單字段 (Drupal 7 - Creating dependent autocomplete form fields)

創建自定義字段格式化程序不起作用 (Creating Custom Field Formatter is not working)

Render ruang putih dalam html - Drupal 7? (White space render in html - Drupal 7?)

File impor Drupal (Drupal import files)

Drupal 7 - Views.css 和 CTools.css 未加載 (Drupal 7 - Views.css and CTools.css not loaded)

Я хачу ўсталяваць Drupal у сваёй сістэме Windows, у мяне ўжо ўсталяваны wamp, ці варта мне ўсталёўваць aquiadrupal? (I want to install Drupal on my windows system, I already have wamp installed should I install aquiadrupal?)

無法向節點 drupal-7 添加標籤 (Not able to add tags to the node drupal-7)

如何點擊觸發非本地 jQuery 插件的操作? (How to onclick-trigger a non-native jQuery plugin's action?)

如何將類添加到 Drupal 7 區域? (How to add a class to a Drupal 7 region?)

在 Drupal 7 中自定義 Md Megamenu 的樣式 (Customizing styles for Md Megamenu in Drupal 7)







留言討論