[GH-ISSUE #5096] OAuth2 authentication flow via the NetBird client,with error code ERR_INVALID_RESPONSE #9886

Open
opened 2026-08-05 01:23:52 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @openapphub on GitHub (Jan 12, 2026).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/5096

Describe the problem

When initiating the OAuth2 authentication flow via the NetBird client, the browser briefly displays an error page stating "This site can't be reached" with error code ERR_INVALID_RESPONSE. The URL involved is the authorization endpoint:
https://netbird.xxx/oauth2/auth?audience=netbird-cli&client_id=netbird-cli&code_challenge=_Kg9WQAtnEkloId6SmK_jD9Xu-c9Uo6D9FBswLAxWyY&code_challenge_method=S256&login_hint=mr.xxx%40gmail.com&prompt=login&redirect_uri=http%3A%2F%2Flocalhost%3A53000%2F&response_type=code&scope=openid+profile+email+offline_access&state=e5a9c8f3eb35fd3a7e584657bd62384b323954329d90af7a

After a short delay (or after the browser handles the error), the page automatically redirects to the correct login page (/oauth2/auth/local) and the authentication proceeds successfully.

To Reproduce

Steps to reproduce the behavior:

  1. Configure NetBird Dashboard and Management service behind an Nginx reverse proxy.
  2. Enable EmbeddedIDP in the management.json configuration.
  3. Trigger a login flow (e.g., via netbird-cli or Dashboard).
  4. Observe the browser showing ERR_INVALID_RESPONSE on the /oauth2/auth endpoint before redirecting to the correct local login view.

Expected behavior

The browser should immediately and seamlessly redirect from /oauth2/auth to /oauth2/auth/local (or the appropriate IdP handler) without displaying a connection error.

Are you using NetBird Cloud?

No, self-hosted.

NetBird version

[Please fill in your version, e.g., v0.28.0]

Is any other VPN software installed?

No.

Debug output

N/A (Network/Proxy level issue)

Screenshots

None available, but the browser error message is:
ERR_INVALID_RESPONSE
The webpage at ... might be temporarily down or it may have moved permanently to a new address.

Additional context

Configuration:
I am using Nginx as a reverse proxy in front of the NetBird Management service.

Test Analysis:
Running curl -I https://netbird.xxx/oauth2/auth returns:

HTTP/2 302 
location: /oauth2/auth/local
...

The upstream service correctly returns a 302 redirect with a relative path. However, the browser interprets the response as invalid.

Nginx Config:
The relevant Nginx configuration for /oauth2 is as follows:

location /oauth2 {
    proxy_pass http://netbird_management;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Proto https;
  
    proxy_buffering off;
    proxy_cache_bypass $http_upgrade;
    add_header Cache-Control "no-cache, no-store, must-revalidate" always;
    add_header Pragma "no-cache" always;
    add_header Expires "0" always;
  
    proxy_hide_header Content-Type;
    proxy_pass_header Content-Type;
  
    proxy_intercept_errors off;
  
    proxy_connect_timeout 10s;
    proxy_send_timeout 10s;
    proxy_read_timeout 10s;
}

Potential Cause:
It appears that Nginx is passing the 302 response from the upstream service to the client, but the location header (/oauth2/auth/local) is causing the browser to throw ERR_INVALID_RESPONSE. This often happens if the response headers are malformed or if the location header is not properly rewritten to an absolute URL (e.g., https://netbird.xxx/oauth2/auth/local) when passing through proxies that enforce strict header validation.

Have you tried these troubleshooting steps?

  • Reviewed client troubleshooting (if applicable)
  • Checked for newer NetBird versions
  • Searched for similar issues on GitHub (including closed ones)
  • Restarted the NetBird client
  • Disabled other VPN software
  • Checked firewall settings
Originally created by @openapphub on GitHub (Jan 12, 2026). Original GitHub issue: https://github.com/netbirdio/netbird/issues/5096 **Describe the problem** When initiating the OAuth2 authentication flow via the NetBird client, the browser briefly displays an error page stating "This site can't be reached" with error code `ERR_INVALID_RESPONSE`. The URL involved is the authorization endpoint: `https://netbird.xxx/oauth2/auth?audience=netbird-cli&client_id=netbird-cli&code_challenge=_Kg9WQAtnEkloId6SmK_jD9Xu-c9Uo6D9FBswLAxWyY&code_challenge_method=S256&login_hint=mr.xxx%40gmail.com&prompt=login&redirect_uri=http%3A%2F%2Flocalhost%3A53000%2F&response_type=code&scope=openid+profile+email+offline_access&state=e5a9c8f3eb35fd3a7e584657bd62384b323954329d90af7a` After a short delay (or after the browser handles the error), the page automatically redirects to the correct login page (`/oauth2/auth/local`) and the authentication proceeds successfully. **To Reproduce** Steps to reproduce the behavior: 1. Configure NetBird Dashboard and Management service behind an Nginx reverse proxy. 2. Enable EmbeddedIDP in the `management.json` configuration. 3. Trigger a login flow (e.g., via `netbird-cli` or Dashboard). 4. Observe the browser showing `ERR_INVALID_RESPONSE` on the `/oauth2/auth` endpoint before redirecting to the correct local login view. **Expected behavior** The browser should immediately and seamlessly redirect from `/oauth2/auth` to `/oauth2/auth/local` (or the appropriate IdP handler) without displaying a connection error. **Are you using NetBird Cloud?** No, self-hosted. **NetBird version** [Please fill in your version, e.g., v0.28.0] **Is any other VPN software installed?** No. **Debug output** N/A (Network/Proxy level issue) **Screenshots** None available, but the browser error message is: `ERR_INVALID_RESPONSE` `The webpage at ... might be temporarily down or it may have moved permanently to a new address.` **Additional context** **Configuration:** I am using Nginx as a reverse proxy in front of the NetBird Management service. **Test Analysis:** Running `curl -I https://netbird.xxx/oauth2/auth` returns: ```http HTTP/2 302 location: /oauth2/auth/local ... ``` The upstream service correctly returns a 302 redirect with a relative path. However, the browser interprets the response as invalid. **Nginx Config:** The relevant Nginx configuration for `/oauth2` is as follows: ```nginx location /oauth2 { proxy_pass http://netbird_management; proxy_http_version 1.1; proxy_set_header X-Forwarded-Proto https; proxy_buffering off; proxy_cache_bypass $http_upgrade; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; add_header Expires "0" always; proxy_hide_header Content-Type; proxy_pass_header Content-Type; proxy_intercept_errors off; proxy_connect_timeout 10s; proxy_send_timeout 10s; proxy_read_timeout 10s; } ``` **Potential Cause:** It appears that Nginx is passing the 302 response from the upstream service to the client, but the `location` header (`/oauth2/auth/local`) is causing the browser to throw `ERR_INVALID_RESPONSE`. This often happens if the response headers are malformed or if the `location` header is not properly rewritten to an absolute URL (e.g., `https://netbird.xxx/oauth2/auth/local`) when passing through proxies that enforce strict header validation. **Have you tried these troubleshooting steps?** - [x] Reviewed [client troubleshooting](https://docs.netbird.io/how-to/troubleshooting-client) (if applicable) - [x] Checked for newer NetBird versions - [x] Searched for similar issues on GitHub (including closed ones) - [x] Restarted the NetBird client - [x] Disabled other VPN software - [x] Checked firewall settings ```
saavagebueno added the triage-needed label 2026-08-05 01:23:52 -04:00
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#9886