From 4952b3a2d6123be72d24d8b467c435b4dd51fd63 Mon Sep 17 00:00:00 2001 From: TruongSinh Tran-Nguyen Date: Thu, 13 Apr 2023 15:38:49 -0500 Subject: [PATCH] fix(proxy): turn off nginx_proxy_buffer (#2246) * Refactor poxy_* directives Move from location to server context, as they are identical * Disable proxy_request_buffering proxy_buffering is already off, no reason to have proxy_request_buffering on. In fact, leaving it on can cause nginx to (temporarily) use a lot of disk space during uploads --- nginx/templates/default.conf.template | 41 ++++++++++----------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/nginx/templates/default.conf.template b/nginx/templates/default.conf.template index 7946d8697d..db5d658603 100644 --- a/nginx/templates/default.conf.template +++ b/nginx/templates/default.conf.template @@ -43,20 +43,22 @@ server { image/svg+xml text/css; - location /api { - proxy_buffering off; - proxy_buffer_size 16k; - proxy_busy_buffers_size 24k; - proxy_buffers 64 4k; - proxy_force_ranges on; + proxy_buffering off; + proxy_request_buffering off; + proxy_buffer_size 16k; + proxy_busy_buffers_size 24k; + proxy_buffers 64 4k; + proxy_force_ranges on; - proxy_http_version 1.1; - proxy_set_header Host $http_host; - proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $forwarded_protocol; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; + proxy_http_version 1.1; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $forwarded_protocol; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + location /api { rewrite /api/(.*) /$1 break; @@ -64,19 +66,6 @@ server { } location / { - proxy_buffering off; - proxy_buffer_size 16k; - proxy_busy_buffers_size 24k; - proxy_buffers 64 4k; - proxy_force_ranges on; - - proxy_http_version 1.1; - proxy_set_header Host $http_host; - proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $forwarded_protocol; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; proxy_pass ${IMMICH_WEB_SCHEME}web; }