Nginx Proxy Guard

Features

ForwardAuth

ForwardAuth makes nginx ask an external authentication service "is this user signed in?" before a request to a proxy host is passed to the backend. It is built on nginx auth_request.

The service answersNPG does
Signed inPasses the request to the backend, with user details such as name, groups and email added as headers.
Not signed inRedirects to the service's sign-in page (302).

An auth provider is defined once and can be attached to many hosts. This feature is about signing in the people who visit your proxy hosts. To sign in to the NPG admin panel itself with SSO, see Signing in with SSO.

Where it is

The Auth Providers item in the top menu. It is shown to roles with the Auth Providers permission area.

Auth Providers (ForwardAuth) list and the Add Auth Provider dialog
Auth Providers (ForwardAuth) list and the Add Auth Provider dialog

Supported types

TypeAuth Service URLHeaders passed to the backend
AutheliaThe Authelia server address (for example http://192.0.2.20:9091). NPG checks /api/authz/auth-request under it. Requires Authelia 4.37 or later, and the session cookie domain must be a parent of every protected host and the portal.Remote-User, Remote-Groups, Remote-Name, Remote-Email
AuthentikThe outpost address. The embedded outpost is port 9000 of the Authentik server. NPG adds a /outpost.goauthentik.io path to the host and passes it to the outpost.X-authentik-username, X-authentik-groups, X-authentik-email, X-authentik-name, X-authentik-uid, X-authentik-entitlements
Custom (ForwardAuth)The address of an auth_request-compatible verifier such as oauth2-proxyNot set in the panel

The Custom type adds these fields.

FieldDescription
Verify PathThe check path appended to the Auth Service URL, for example /oauth2/auth.
Sign-in RedirectLocation header follows the redirect the verifier returns. Redirect template sends the visitor to the URL below.
Sign-in Redirect URLThe address used with Redirect template, for example /oauth2/sign_in?rd=$scheme://$host$request_uri.
Forward Set-CookiePasses the verifier's Set-Cookie on to the browser.
Large header buffersFor verifiers that send large response headers (JWTs, group lists). Applied automatically to the Authentik type.

Setting it up

  1. Click Auth Providers → Add Auth Provider.
  2. Enter a Name, choose the Type and enter the Auth Service URL. The address must be reachable from nginx (the npg-proxy container). In the standard installation nginx uses the host network, so host IP:port is the right form. If the service runs in a Docker container, you can choose it with Pick from Docker; when the container restarts with a new IP, NPG finds and updates it automatically.
  3. Click Create.
  4. Attach it to the host you want to protect: Proxy host → edit → Security tab → Auth Providers (ForwardAuth), choose the provider and save. You can also attach hosts from the provider list with Hosts → Attach a host.
  5. If some paths must stay open without signing in, list them in Bypass paths (one per line) in the same place. A path starts with / and contains no spaces or ; { } #.
/api
/healthz

Checking it worked

Open the protected host in a private browser window. If you land on the service's sign-in page, it works. After signing in, the original site should open. Bypass paths open without signing in.

How it works with other features

  • It cannot be combined with a challenge (CAPTCHA). nginx allows only one auth_request per location. Attaching refuses hosts with challenge mode on, and on a host with ForwardAuth the geo-blocking challenge mode blocks instead of showing a CAPTCHA.
  • It cannot be attached to a host with a custom location /.
  • An access list with usernames and passwords cannot be attached to a ForwardAuth host. See Access lists and basic auth.
  • If an access list with Satisfy Any is attached to a ForwardAuth host, addresses the list allows get in without the ForwardAuth sign-in. Turn Satisfy Any off to require both.
  • Other security features such as the WAF, geo blocking and the bot filter still apply, independently of ForwardAuth.
  • Auth providers are included in backups.

Limits

  • The protected host must use HTTPS. Authelia and Authentik refuse requests for http addresses.
  • Deleting an auth provider leaves the hosts that used it unprotected. The delete confirmation shows how many hosts are affected.
  • For the Custom type, which response headers are passed to the backend cannot be set in the panel.