Skip to content

SSO login redirect (OIDC and SAML) uses server's internal IP instead of public hostname behind a reverse proxy — same root cause affects both protocols #901

Open

Description

@rtlabcode

Summary

On a single-server Kasm Workspaces CE 1.19.0 install deployed behind a reverse proxy (public hostname differs from the server's own detected identity), the final "land the browser in a logged-in session" redirect after a successful SSO login uses the server's own internal/LAN IP address instead of the public hostname the login flow came in through — for both OIDC and SAML, via two different mechanisms that share the same underlying root cause. This makes SSO login completely non-functional in this (very common) deployment topology, despite the identity-provider authentication itself succeeding correctly every time.

This looks related to #552 and #822 (OIDC) and possibly #648 (SAML, IdP-initiated), but I wanted to file a combined report since I was able to fully isolate the mechanism on both protocols and confirm it's the same shared issue, not two separate bugs — and confirm neither is fixable via any documented configuration option.

Environment

  • Kasm Workspaces CE 1.19.0
  • Single-server install, Ubuntu 24.04.4 LTS
  • Deployed behind a reverse proxy (Caddy) — public hostname kasm.example.com, proxy → kasm-backend-internal-ip:8443
  • Identity provider: Okta (tested both OIDC and SAML)

Symptom 1 — OIDC

After a fully successful Okta OIDC authentication (confirmed via kasm_api logs: token exchange succeeds, email/groups attributes read correctly, correct Kasm group assigned), /api/oidc_callback returns a 302 whose Location header is:

https://<internal-server-ip>/#/sso/<session>/<jwt>

No port, and nothing external listens on that internal IP — the browser fails to connect. Confirmed directly via the actual Location response header in browser DevTools, not inferred.

Symptom 2 — SAML

Same underlying issue, different mechanism. The python3-saml/OneLogin toolkit's Destination validation check rejects the response:

invalid_response: The response was received at https://<internal-server-ip>/api/acs instead of https://kasm.example.com/api/acs/?id=...

Working around this by setting the (undocumented, not exposed in the Admin UI) saml_config.strict database column to false gets past this specific check — but then hits the identical symptom-1-style failure downstream, confirming this is genuinely shared, protocol-agnostic code.

What I confirmed is NOT the cause (exhaustively ruled out)

  • Reverse proxy header forwarding — Host, X-Forwarded-Proto, X-Forwarded-Port all confirmed correctly forwarded end-to-end (inspected both the external proxy's config and Kasm's own internal kasm_proxy nginx location /api/ block directly)
  • server_hostname in /opt/kasm/current/conf/app/api/api.app.config.yaml — edited to the correct public hostname, systemctl restart kasm, and separately a full docker compose down/up (true container recreation) — no effect on the OIDC redirect
  • upgrade.sh -p <public-hostname> (the documented public-hostname flag) — ran a full reconfigure pass, confirmed the YAML value updated correctly and all containers recreated — no effect on the OIDC redirect
  • oidc_configs.hostname (the Admin UI's OpenID config "Hostname" field, described in docs as "multi-tenant hostname scoping") — set to the correct public hostname, confirmed persisted to the database — no effect on the OIDC redirect
  • Postgres schema sweep for any other hostname/IP-holding column — servers.hostname (literal placeholder "proxy"), zones.proxy_hostname/proxy_port (a separate mechanism, confirmed scoped to session/desktop-streaming routing only, not SSO login), managers.manager_hostname (correctly set already) — nothing else found
  • Container environment variables and Docker network mode — kasm_api runs on the internal Docker bridge network, and an in-container self-connect test resolves to the bridge IP, not the bad internal-LAN-IP value — rules out simple self-IP autodetection as the mechanism
  • A reverse-proxy-side header rewrite is possible for the OIDC case (confirmed working, byte-correct — happy to share the exact config) — but even with a corrected, same-origin Location, the browser still fails to complete the session, landing on Kasm's own generic "You are currently offline" fallback screen. This reproduces identically across multiple fresh Incognito sessions (ruled out browser/Service-Worker caching as a factor) — suggesting the client-side JS/Service Worker itself doesn't correctly complete session establishment via a same-origin SSO landing redirect either, a second bug layered on top of the first.

Impact

SSO login (with automatic group-based provisioning) is completely non-functional for any single-server deployment where the public-facing hostname differs from the server's own detected/configured identity — i.e., essentially any production reverse-proxied deployment. This forces either manual per-user account creation (not viable at any real scale) or abandoning SSO entirely.

Ask

Given this affects both supported SSO protocols via the same root mechanism, could this get elevated/consolidated with #552 and #822? Happy to provide full logs, DB inspection output, or test further against a patched build if that would help.

Activity

  1. rtlabcode commented on Nov 17, 2026

    @rtlabcode
    Author

    Update (2026-11-17): login and sessions work when Kasm is reached directly, without the external reverse proxy

    Follow-up to my original report. I re-tested with the external reverse proxy (Caddy) removed from the path entirely, and SSO now works end to end on the same Kasm install.

    Environment (unchanged from the original report)

    • Kasm Workspaces CE 1.19.0, single server, static images, installed with -L 8443
    • IdP: Okta, OIDC (authorization code flow), JIT provisioning + group mapping
    • Clients reach the lab through a zero-trust network access product (hostname → private IP)

    What changed for the test

    Before (failing) Now (working)
    Path Browser → Caddy :443 → Kasm https://<kasm-host-ip>:8443 Browser → Kasm https://kasm.example.internal:8443 directly
    Public URL https://kasm.example.internal (no port) https://kasm.example.internal:8443
    TLS on Kasm Kasm self-signed (Caddy terminated TLS with a trusted cert) Trusted internal-CA wildcard cert installed as kasm_nginx.crt/.key
    Headers Kasm saw Set by Caddy, incl. X-Forwarded-Port: 443, X-Forwarded-Proto: https None from an external proxy; kasm_proxy's own maps derive the port (8443) from the Host header
    OIDC redirect URI (IdP + Kasm config) https://kasm.example.internal/api/oidc_callback https://kasm.example.internal:8443/api/oidc_callback
    Zone → Proxy Hostname / Port $request_host$ / 8443 (default, unchanged) same

    I also added this to conf/nginx/services.d/client_api.conf (location /api/) as a safety net for the bare-IP redirect:

    proxy_redirect https://<kasm-host-ip>/      https://kasm.example.internal:8443/;
    proxy_redirect https://<kasm-host-ip>:8443/ https://kasm.example.internal:8443/;

    Result

    • OIDC login completes. POST /api/sso → IdP → GET /api/oidc_callback (302) → POST /api/login_saml (200) → dashboard. No "You are currently offline" screen.
    • JIT user created and IdP group mapped to the Kasm group correctly.
    • Workspace sessions (Chrome, Obsidian) launch and stream normally.

    What this suggests (not confirmed)

    • Bug 2 (the "offline" screen after a correct same-origin redirect) did not reproduce without the external proxy. One plausible explanation is a port mismatch in our old setup rather than a Kasm defect. The external proxy forced X-Forwarded-Port: 443 and served users on 443, while the Zone's Proxy Port stayed at the default 8443 with Proxy Hostname $request_host$. After the SSO landing, the client may then have tried kasm.example.internal:8443, which our network path didn't expose for that hostname at the time. I haven't proven this. If it's right, the fix behind a 443 reverse proxy would be setting the Zone Proxy Port to 443, and the docs could call that out more clearly.
    • Bug 1 (callback redirect to the bare server IP): with direct access, the browser receives Location: https://kasm.example.internal:8443/#/sso/... (correct host and port). Because the proxy_redirect safety net above is in place, I haven't yet confirmed whether kasm_api itself now builds this correctly or still emits the bare IP and nginx rewrites it. I can test without the rewrite if that helps.

    Ask

    • Can you confirm whether the Zone proxy port mismatch above would produce the "offline" screen after an SSO login?
    • If bug 1 is still present when reached directly: is building the post-login redirect from the server's own address, rather than the request Host/X-Forwarded-*, expected in 1.19.0?

    Happy to provide logs or test a build.

  2. raphael-pankl commented on Dec 1, 2026

    @raphael-pankl

    Having the same setup (public ip to caddy as reverse proxy > to kasm, kasm with OIDC through Authentik) I had the same issue with the redirect to the IP of kasm and it resolved by setting the Host header in caddy config

            reverse_proxy https://kasmserver.domain.local {
                    transport http {
                            tls_insecure_skip_verify
                    }
                    header_up Host kasm.example.org
            }
    
    

    Maybe this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions