OpenID auth issues via NGINX: NPE on User creation & 401 on Device creation

Tomas Pekar 23 hours ago

Hi everyone,
I'm running into an issue with Traccar running behind an NGINX reverse proxy when users authenticate via OpenID.

The Problem:
When logged in via OpenID, performing administrative actions leads to the following errors:

  1. Creating a new user: Throws an exception:
    java.lang.NullPointerException: Cannot invoke "org.traccar.model.User.getAdministrator()" because the return value of "org.traccar.api.security.PermissionsService.getUser(long)" is null
  2. Creating a new device: Throws an exception:
    jakarta.ws.rs.WebApplicationException: HTTP 401 Unauthorized

What Works:
Local Login + NGINX: Logging in with a standard local account (email/password) through NGINX works completely fine (both user and device creation succeed).
Direct Access (No NGINX): Bypassing NGINX entirely and logging in via OpenID directly against Traccar works without any issues.

Has anyone encountered similar issue?

Anton Tananaev 17 hours ago

Your NGINX config is likely missing proxy_set_header Host $host; on the Traccar location block. OpenID login lands via a browser redirect (no Origin header), so Traccar falls back to comparing the request's Origin host against the Host header it receives — if NGINX isn't forwarding the original Host, that check fails, the session isn't recognized as authenticated, and you get the 401 on protected requests and the NPE on the unauthenticated fallback path. Password login doesn't hit this because it sends Origin directly. Add the header and it should resolve.

Tomas Pekar 16 hours ago

Hello, issue was resolved by downgrading to docker image 6.14.4 (from 6.15.3). I have found out that i can create user/device (even through nginx) via API client. These clues make me think that the issue is somewhere in the UI of version 6.15.3.

Anton Tananaev 15 hours ago

No, it's not the UI. It's a security fix that would recommend picking up.