docs: update TinyAuth v5 setup guide - #496
Conversation
| location = /tinyauth { | ||
| internal; | ||
| proxy_pass http://tinyauth/api/auth/nginx; | ||
| proxy_pass_request_body off; | ||
| proxy_set_header Content-Length ""; |
There was a problem hiding this comment.
The
keepalive 16 directive in the upstream block has no effect without proxy_http_version 1.1 and proxy_set_header Connection "" in the location block that proxies to it. Without these two directives, Nginx defaults to HTTP/1.0 for upstream requests, which always closes the connection after each request and never reuses the keepalive pool. As a result, every auth subrequest opens a fresh TCP connection to TinyAuth, making keepalive 16 a no-op.
| location = /tinyauth { | |
| internal; | |
| proxy_pass http://tinyauth/api/auth/nginx; | |
| proxy_pass_request_body off; | |
| proxy_set_header Content-Length ""; | |
| location = /tinyauth { | |
| internal; | |
| proxy_pass http://tinyauth/api/auth/nginx; | |
| proxy_pass_request_body off; | |
| proxy_set_header Content-Length ""; | |
| proxy_http_version 1.1; | |
| proxy_set_header Connection ""; |
| auth_request /tinyauth; | ||
| auth_request_set $tinyauth_location $upstream_http_x_tinyauth_location; | ||
| error_page 401 403 =302 $tinyauth_location; |
There was a problem hiding this comment.
If TinyAuth returns a 401 or 403 without the
X-Tinyauth-Location response header (e.g., on a backend error or misconfiguration), $tinyauth_location will be an empty string. Nginx interprets an empty redirect target as a redirect to /, which immediately triggers another auth subrequest that fails again, producing a redirect loop. Adding a fallback error_page for 5xx codes avoids this.
| auth_request /tinyauth; | |
| auth_request_set $tinyauth_location $upstream_http_x_tinyauth_location; | |
| error_page 401 403 =302 $tinyauth_location; | |
| auth_request /tinyauth; | |
| auth_request_set $tinyauth_location $upstream_http_x_tinyauth_location; | |
| error_page 401 403 =302 $tinyauth_location; | |
| # Fallback if TinyAuth does not return X-Tinyauth-Location. | |
| error_page 500 502 503 504 /50x.html; |
| curl https://panel.remnawave.com/api/example \ | ||
| -H "X-Api-Key: Basic $(printf 'username:password' | base64)" \ | ||
| -H "Authorization: Bearer application-token" |
There was a problem hiding this comment.
base64 on macOS (and some Linux defaults) wraps output at 76 characters. For credentials longer than ~55 bytes the encoded string will contain a newline, breaking the header value sent by curl. Using base64 | tr -d ' ' ensures a single-line output regardless of platform.
| curl https://panel.remnawave.com/api/example \ | |
| -H "X-Api-Key: Basic $(printf 'username:password' | base64)" \ | |
| -H "Authorization: Bearer application-token" | |
| curl https://panel.remnawave.com/api/example \ | |
| -H "X-Api-Key: Basic $(printf 'username:password' | base64 | tr -d '\n')" \ | |
| -H "Authorization: Bearer application-token" |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
No description provided.