From 84345be7e2c5df484c672539dafe04bece124a91 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Sat, 29 Jan 2022 19:07:44 +0100 Subject: [PATCH] Deactivated buffering to reduce reverse proxy as bottle neck --- roles/native-docker-reverse-proxy/readme.md | 4 ++++ .../templates/proxy_pass.conf.j2 | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/roles/native-docker-reverse-proxy/readme.md b/roles/native-docker-reverse-proxy/readme.md index 38356c94..2c941e8f 100644 --- a/roles/native-docker-reverse-proxy/readme.md +++ b/roles/native-docker-reverse-proxy/readme.md @@ -11,3 +11,7 @@ curl -I {{address}} ## performance - https://stackoverflow.com/questions/33703230/caching-images-on-all-folder-levels-of-nginx-reverse-proxy - https://www.tweaked.io/guide/nginx-proxying/ +- https://serverfault.com/questions/796735/nginx-reverse-proxy-is-slow/796740 +- https://serverfault.com/questions/741610/what-is-the-difference-between-proxy-request-buffering-and-proxy-buffering-on-ng +- https://askubuntu.com/questions/1103626/should-i-enable-client-max-body-size-proxy-request-buffering-and-proxy-bufferin +- https://serverfault.com/questions/692577/whats-the-difference-between-proxy-buffer-and-proxy-cache-module-in-nginx-confi diff --git a/roles/native-docker-reverse-proxy/templates/proxy_pass.conf.j2 b/roles/native-docker-reverse-proxy/templates/proxy_pass.conf.j2 index dc361ea3..4e42384c 100644 --- a/roles/native-docker-reverse-proxy/templates/proxy_pass.conf.j2 +++ b/roles/native-docker-reverse-proxy/templates/proxy_pass.conf.j2 @@ -6,11 +6,16 @@ location / proxy_pass http://127.0.0.1:{{http_port}}/; {% endif %} + # headers proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; + # deactivate buffering + proxy_buffering off; + proxy_request_buffering off; + # timeouts proxy_connect_timeout 1s; proxy_send_timeout 300s; @@ -19,6 +24,7 @@ location / # cache media files location ~* \.(gif|ico|jpg|jpeg|png|svg|mp4|mp3|pdf)$ { + proxy_buffering on; proxy_cache cache; proxy_cache_key $host$uri$is_args$args; proxy_cache_revalidate on; @@ -37,6 +43,7 @@ location / # cache content location ~* \.(html|css|js)$ { + proxy_buffering on; proxy_cache cache; proxy_cache_key $host$uri$is_args$args; proxy_cache_revalidate on;