Open
Description
Hello.
I have a django application. Let's assume I have empty django project created by:
mkdir nginxtest
cd nginxtest/
python -m venv .venv
source .venv/bin/activate
pip install -U pip wheel django
django-admin startproject mytest . # See https://docs.djangoproject.com/en/3.2/intro/tutorial01/
./manage.py migrate
vim mytest/settings.py # Add: STATIC_ROOT = './static/'
./manage.py collectstatic
./manage.py runserver 0.0.0.0:8000
On nginx side I have the following configuration:
location / {
proxy_connect_timeout 10s;
#proxy_buffering off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_cache_valid 2m;
proxy_cache_valid 404 1m;
proxy_cache_key $uri;
proxy_cache_use_stale timeout updating error http_502 http_503;
proxy_cache proxy_cache;
js_header_filter utils.bohHeaderFilter;
js_body_filter utils.bohBodyFilter;
proxy_pass http://192.168.56.101:8000;
}
utils.js
function bohBodyFilter(r, data, flags) {
r.sendBuffer(data, flags);
}
function bohHeaderFilter(r) {
}
export default { bohHeaderFilter, bohBodyFilter };
So when I request resource with Content-Type!=text/html I get normal headers and empty body.
wget -v -S http://localhost/static/admin/css/fonts.css
If I comment js_header_filter and js_body_filter - everything is OK.
If I comment proxy_cache_use_stale WGET just freezes on getting body.
If I uncomment "proxy_buffering off;" - everything is OK.
nginx 1.20.1
njs 0.6.1