Skip to content

Commit e4ea67f

Browse files
WPB-21140: Add configurable large_client_header_buffers to nginz for large SAML responses (#4816)
* Add configurable large_client_header_buffers to nginz for large SAML responses - Fixes "414 Request-URI Too Large" errors during SAML SSO login - when using HTTP Redirect binding with large SAMLResponse parameters - Add troubleshooting documentation to SSO docs * Add changelog * Update the instruction * Update docs/src/understand/single-sign-on/trouble-shooting.md Co-authored-by: Julia Longtin <[email protected]> --------- Co-authored-by: Julia Longtin <[email protected]>
1 parent 1c2d211 commit e4ea67f

File tree

5 files changed

+73
-3
lines changed

5 files changed

+73
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add configurable `large_client_header_buffers` to nginz helm chart for handling large SAML SSO responses
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add troubleshooting documentation for "414 Request-URI Too Large" errors during SAML SSO login

charts/nginz/templates/conf/_nginx.conf.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ http {
4747
server_names_hash_bucket_size 64;
4848
server_name_in_redirect off;
4949
50-
large_client_header_buffers 4 8k;
50+
large_client_header_buffers {{ .Values.nginx_conf.large_client_header_buffers | default "4 8k" }};
5151

5252

5353
#
@@ -196,7 +196,7 @@ http {
196196

197197
{{- $validUpstreams := include "valid_upstreams" . | fromJson }}
198198
{{- range $name, $_ := $validUpstreams }}
199-
upstream {{ $name }}{{ if hasKey $.Values.nginx_conf.upstream_namespace $name }}.{{ get $.Values.nginx_conf.upstream_namespace $name }}{{end}} {
199+
upstream {{ $name }}{{ if hasKey $.Values.nginx_conf.upstream_namespace $name }}.{{ get $.Values.nginx_conf.upstream_namespace $name }}{{end}} {
200200
zone {{ $name }} 64k; # needed for dynamic DNS updates
201201
least_conn;
202202
keepalive 32;

charts/nginz/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ nginx_conf:
3131
worker_rlimit_nofile: 131072
3232
worker_connections: 65536
3333

34+
# Sets the maximum number and size of buffers used for reading large client request headers.
35+
# The request line (URL including query params) cannot exceed the size of one buffer.
36+
# Format: "number size" (e.g., "4 8k", "4 32k", "8 16k")
37+
# Increase this if you see "414 Request-URI Too Large" errors, particularly with SAML SSO
38+
# using HTTP Redirect binding with large SAMLResponse query parameters.
39+
large_client_header_buffers: "4 8k"
40+
3441
# The domain to identify the environment, it is used to build the deeplink URLs
3542
# and to allow CORS requests from the webapp. Check the 'allowlisted_origins'.
3643
# external_env_domain: example.com

docs/src/understand/single-sign-on/trouble-shooting.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<a id="trouble-shooting-faq"></a>
22
> ##### Contents
3-
>
3+
>
44
> * [Trouble shooting & FAQ](#id1)
55
> * [Reporting a problem with user provisioning or SSO authentication](#reporting-a-problem-with-user-provisioning-or-sso-authentication)
66
> * [Can I use SCIM without SAML?](#can-i-use-scim-without-saml)
@@ -17,6 +17,7 @@
1717
> * [Can I distribute a URL to my users that contains the login code?](#can-i-distribute-a-url-to-my-users-that-contains-the-login-code)
1818
> * [(Theoretical) name clashes in SAML NameIDs](#theoretical-name-clashes-in-saml-nameids)
1919
> * [After logging in via IdP page, the redirection to the wire app is not happening](#after-logging-in-via-idp-page-the-redirection-to-the-wire-app-is-not-happening)
20+
> * [Getting "414 Request-URI Too Large" error during SAML SSO login](#getting-414-request-uri-too-large-error-during-saml-sso-login)
2021
2122
# Trouble shooting & FAQ
2223

@@ -400,3 +401,63 @@ See also:
400401
[1](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/form-action),
401402
[2](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy),
402403
[3](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
404+
405+
## Getting "414 Request-URI Too Large" error during SAML SSO login
406+
407+
**Problem:** After authenticating successfully at the IdP (Identity Provider), users are redirected back to Wire but encounter a `414 Request-URI Too Large` error. The URL contains a very long `SAMLResponse` query parameter.
408+
409+
**Example URL causing the error:**
410+
```
411+
https://nginz-https.example.com/sso/metadata?SAMLResponse=rZrXDq...very-long-base64-encoded-string...
412+
```
413+
414+
**Root cause:** This error occurs when using SAML with **HTTP Redirect binding** (where the SAML response is sent as a URL query parameter). Large SAML responses - particularly those with many user attributes, group memberships, or other metadata - can exceed nginx's default URL buffer size limit of 32KB.
415+
416+
### Solutions
417+
418+
You have two options to resolve this issue:
419+
420+
#### Option 1: Switch to SAML HTTP POST Binding (Recommended)
421+
422+
Configure your IdP to use **HTTP POST binding** instead of HTTP Redirect binding. With POST binding, the SAML response is sent in the request body rather than the URL, which avoids URL length limitations.
423+
424+
**How to configure:**
425+
1. In your IdP (e.g., Okta, Azure AD, Authentik, etc.), locate the SAML application configuration
426+
2. Change the binding from "Redirect" to "POST" for the Assertion Consumer Service (ACS)
427+
3. Save and test the SSO login flow
428+
429+
Consult your IdP's documentation for specific instructions on changing SAML bindings.
430+
431+
#### Option 2: Increase nginx URL Buffer Size
432+
433+
If you cannot change the IdP configuration to use POST binding, you can increase nginx's URL buffer size in the Wire backend:
434+
435+
1. **Update your nginz helm chart values** (e.g., in your `values.yaml` override file):
436+
437+
```yaml
438+
nginx_conf:
439+
# Increase buffer size to handle large SAML responses in URLs
440+
# Format: "number size" - request line must fit in one buffer
441+
large_client_header_buffers: "4 32k" # Allows URLs up to 32KB
442+
```
443+
444+
For even larger SAML responses (if 32KB is still not enough):
445+
```yaml
446+
nginx_conf:
447+
large_client_header_buffers: "4 64k" # Allows URLs up to 64KB
448+
```
449+
450+
2. **Redeploy the nginz service** with the updated configuration
451+
452+
3. **Test the SSO login flow** again
453+
454+
**Note:** The first value is the number of buffers, and the second is the size of each buffer. The request line (URL) must fit within a **single buffer**, not across multiple buffers. So `4 32k` means up to 32KB per URL, with 4 buffers available total (128KB) for all headers.
455+
456+
### How to determine which binding is being used
457+
458+
- **HTTP Redirect binding**: The SAMLResponse appears in the URL as a query parameter (`?SAMLResponse=...`)
459+
- **HTTP POST binding**: The URL is clean with no SAMLResponse parameter; the response is in the request body
460+
461+
### Reference
462+
463+
- Nginx directive documentation: [large_client_header_buffers](http://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers)

0 commit comments

Comments
 (0)