fix(nginx): don't forward request body to Authelia auth subrequest
Authelia's forward-auth endpoint was handed the original Content-Length header of the client request but not the body itself, so it blocked reading bytes that never arrived and finally answered 408. auth_request cannot classify 408, so nginx reported it to the client as 500 + an HTML error page, and the frontend surfaced "Server returned non-JSON" on every upload. Every bodied POST was affected (JSON upload and zip ingest) while plain GETs kept working, which is why the page loaded fine but uploads failed. Payload size was irrelevant: a 60-byte body failed identically to a 300 KB one. With `proxy_pass_request_body off` and an empty Content-Length, Authelia authorises on the forwarded headers alone, which is all forward-auth needs. Applied to both "= /authelia" blocks (vtimeline.zeroq.su and tty.zeroq.su). Verified on a reproduction bench mirroring the production vhost: bodied POSTs went 500 (HTML, 6 s timeout) -> 201 (JSON, ~10 ms).
This commit is contained in:
1 parent
2ab48515b9
commit
a8ffdd8717
1 file changed
+32
@@ -168,6 +168,22 @@ in
|
||||
extraConfig = ''
|
||||
internal;
|
||||
proxy_pass http://127.0.0.1:9091/api/authz/forward-auth;
|
||||
# Never forward the client request body to the auth
|
||||
# subrequest. nginx relays the original Content-Length to
|
||||
# /authelia but does not relay the body itself, so Authelia
|
||||
# blocks waiting for bytes that never arrive and finally
|
||||
# answers 408 — a status `auth_request` cannot classify, so
|
||||
# nginx reports it to the client as 500 + an HTML error
|
||||
# page. Every bodied POST (JSON upload, zip ingest) died
|
||||
# this way while plain GETs worked, which is why the page
|
||||
# loaded fine but uploads failed with "Server returned
|
||||
# non-JSON". Clearing the body and Content-Length makes
|
||||
# Authelia authorise on the forwarded headers alone, which
|
||||
# is all forward-auth needs. Verified on a reproduction
|
||||
# bench: bodied POSTs went 500 (HTML, 6 s timeout) -> 201
|
||||
# (JSON, ~10 ms).
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
proxy_set_header X-Original-URL $request_uri;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
@@ -214,6 +230,22 @@ in
|
||||
extraConfig = ''
|
||||
internal;
|
||||
proxy_pass http://127.0.0.1:9091/api/authz/forward-auth;
|
||||
# Never forward the client request body to the auth
|
||||
# subrequest. nginx relays the original Content-Length to
|
||||
# /authelia but does not relay the body itself, so Authelia
|
||||
# blocks waiting for bytes that never arrive and finally
|
||||
# answers 408 — a status `auth_request` cannot classify, so
|
||||
# nginx reports it to the client as 500 + an HTML error
|
||||
# page. Every bodied POST (JSON upload, zip ingest) died
|
||||
# this way while plain GETs worked, which is why the page
|
||||
# loaded fine but uploads failed with "Server returned
|
||||
# non-JSON". Clearing the body and Content-Length makes
|
||||
# Authelia authorise on the forwarded headers alone, which
|
||||
# is all forward-auth needs. Verified on a reproduction
|
||||
# bench: bodied POSTs went 500 (HTML, 6 s timeout) -> 201
|
||||
# (JSON, ~10 ms).
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
proxy_set_header X-Original-URL $request_uri;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
|
||||
Reference in new issue
Block a user