Forward-auth, for the proxy
Nginx · Traefik · CaddyEvery request passes through Passage before it reaches the app. A 200 forwards it; a 401 or 403 sends the browser back through Passage, which asks for a sign-in or explains that this account has no access. On success the upstream receives the user's name, address, id and admin flag as headers — add one auth_request_set plus proxy_set_header pair per header you want to keep.
# nginx: put one upstream behind Passage
location /auth/ {
internal;
proxy_pass http://localhost:8080;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
location / {
auth_request /auth/nginx;
error_page 401 403 = @login;
auth_request_set $u $upstream_http_x_passage_username;
proxy_set_header X-Passage-Username $u;
proxy_pass http://your-upstream-service;
}
location @login {
set $login https://auth.example.com/auth/start;
return 302 $login?rd=$request_uri;
}
- One block per proxy:
/auth/nginx,/auth/traefik, or a plain redirect through/auth/start. - Covers anything the proxy can reach, including apps with no login at all.
- Works behind an existing TLS termination; Passage never needs a public port of its own.