Prerequisites
Before starting, confirm the following:
- The target service is running and accessible on its internal hostname/port
- Traefik is operational and routing traffic correctly
- Authentik is healthy (check
https://auth.valkyrienexus.com/if/flow/initial-setup/) - You have Authentik admin credentials
- The DNS record for the new service exists in Cloudflare (or will be created via tunnel)
- The Cloudflare Tunnel is running and connected
Step 1: Create the Authentik Application
-
Log into the Authentik admin interface at
https://auth.valkyrienexus.com/if/admin/ -
Navigate to Applications > Applications
-
Click Create and fill in:
- Name: Human-readable name (e.g., "Grafana Dashboard")
- Slug: URL-safe identifier (e.g.,
grafana-dashboard) - Group: Select the appropriate group or leave blank
- Launch URL: The external URL users will access (e.g.,
https://grafana.valkyrienexus.com)
-
Click Create to save the application
Step 2: Create the Provider
Each application needs a provider that defines how authentication works.
For Proxy Authentication (most common)
-
Navigate to Applications > Providers
-
Click Create and select Proxy Provider
-
Configure:
- Name: Match the application name with "Provider" suffix
- Authorization flow: Select
default-provider-authorization-explicit-consentfor first-time consent, ordefault-provider-authorization-implicit-consentfor seamless SSO - External host: The public URL (e.g.,
https://grafana.valkyrienexus.com) - Mode: Forward auth (single application)
-
Under Advanced protocol settings:
- Token validity:
hours=24for standard services,hours=8for sensitive ones
- Token validity:
-
Click Finish and link the provider to the application created in Step 1
For OAuth2/OIDC (if the service supports it)
- Select OAuth2/OpenID Provider instead
- Set the Redirect URIs to the service's callback URL
- Note the Client ID and Client Secret for service configuration
Step 3: Configure Traefik Routing
Add the service to your Traefik dynamic configuration. If using Docker labels:
labels:
- "traefik.enable=true"
- "traefik.http.routers.grafana.rule=Host(`grafana.valkyrienexus.com`)"
- "traefik.http.routers.grafana.entrypoints=websecure"
- "traefik.http.routers.grafana.tls=true"
- "traefik.http.routers.grafana.middlewares=authentik@docker"
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
If using a file-based configuration:
# dynamic/grafana.yml
http:
routers:
grafana:
rule: "Host(`grafana.valkyrienexus.com`)"
entryPoints:
- websecure
service: grafana
middlewares:
- authentik-forward-auth
tls: {}
services:
grafana:
loadBalancer:
servers:
- url: "http://grafana:3000"
The authentik-forward-auth middleware should already be defined in your Traefik static configuration. If not, add it:
http:
middlewares:
authentik-forward-auth:
forwardAuth:
address: "http://authentik-server:9000/outpost.goauthentik.io/auth/traefik"
trustForwardHeader: true
authResponseHeaders:
- X-authentik-username
- X-authentik-groups
- X-authentik-email
- X-authentik-name
- X-authentik-uid
- X-authentik-jwt
- X-authentik-meta-jwks
- X-authentik-meta-outpost
- X-authentik-meta-provider
- X-authentik-meta-app
- X-authentik-meta-version
Step 4: Add the Cloudflare Tunnel Route
If the service should be externally accessible, add a route to your cloudflared configuration:
# cloudflared/config.yml
tunnel: <your-tunnel-id>
credentials-file: /etc/cloudflared/credentials.json
ingress:
# ... existing routes ...
- hostname: grafana.valkyrienexus.com
service: http://traefik:80
# Catch-all (must be last)
- service: http_status:404
After modifying the config, restart the cloudflared service:
# If running as a systemd service
sudo systemctl restart cloudflared
# If running in Docker
docker compose restart cloudflared
Step 5: Create an Authentik Outpost
If this is your first proxy-authenticated service, you need an outpost.
-
Navigate to Applications > Outposts
-
Click Create:
- Name:
traefik-outpost - Type: Proxy
- Integration: Select your Docker or Kubernetes integration
- Applications: Select all applications that should use this outpost
- Name:
-
If you already have an outpost, edit it and add the new application to its application list
Step 6: Set Access Policies
- Navigate to Applications > Applications > select your app
- Go to the Policy / Group / User Bindings tab
- Click Bind existing policy or Create and bind Policy
Common Policy Patterns
Internal users only:
- Bind a Group policy for the
internal-usersgroup - Deny all others
Specific team access:
- Bind a Group policy for the relevant team group
- Set the policy to
ANDif multiple conditions are required
Public with authentication:
- No restrictive policy needed -- any authenticated user can access
- The authentication flow itself is the gate
Step 7: Verify
- Open the external URL in an incognito/private browser window
- Confirm you are redirected to the Authentik login page
- Log in with valid credentials
- Verify the service loads correctly after authentication
- Test with a user who should NOT have access to confirm the policy denies them
- Check Authentik's Events > Logs for the authentication events
Rollback
If something goes wrong:
- Service unreachable: Check Traefik logs for routing errors. Verify the service is running on its expected port.
- Authentication loop: The outpost may not be correctly configured. Check that the outpost includes the application and that the forward-auth middleware URL is correct.
- 403 after login: The access policy is denying the user. Review policy bindings and group membership.
- 502 Bad Gateway: Traefik cannot reach the backend service. Verify the service URL in Traefik configuration and check network connectivity between containers.
To quickly restore access while debugging, you can temporarily remove the authentik-forward-auth middleware from the Traefik router. This bypasses authentication entirely -- only do this on non-sensitive services and revert immediately after debugging.
Maintenance Notes
- When upgrading Authentik, always check the outpost version matches the server version
- Rotate provider tokens periodically (set a calendar reminder)
- Audit application access logs monthly via Events > Logs
- Document each new application in the infrastructure inventory