Skip to content

Nginx Proxy Manager

Nginx Proxy Manager is a popular tool in the homelab community for managing reverse proxies. While it differs from Traefik and Caddy due to Nginx’s lack of native 302 redirect support in the auth_request module, Tinyauth provides API paths specifically designed to work with it.

The following Docker Compose file demonstrates how to set up Nginx Proxy Manager, Whoami, and Tinyauth:

docker-compose.yml
services:
npm:
image: jc21/nginx-proxy-manager:2
restart: unless-stopped
ports:
- 80:80
- 443:443
- 81:81
volumes:
- npm-data:/data
- npm-letsencrypt:/etc/letsencrypt
whoami:
image: traefik/whoami:latest
restart: unless-stopped
tinyauth:
image: ghcr.io/steveiliop56/tinyauth:v5
restart: unless-stopped
environment:
- TINYAUTH_APPURL=http://tinyauth.example.com
- TINYAUTH_AUTH_USERS=user:$$2a$$10$$UdLYoJ5lgPsC0RKqYH/jMua7zIn0g9kPqWmhYayJYLaZQ/FTmH2/u # user:password
volumes:
npm-data:
npm-letsencrypt:

OAuth and access controls can be configured using Docker labels and environment variables. All other configuration is managed through the Nginx Proxy Manager UI.

Create a host for Tinyauth in Nginx Proxy Manager. Configure it as any other host:

Create Tinyauth Host

SSL can be set up if certificates are available.

For protected hosts, such as Whoami, configure the Details tab similarly to the Tinyauth host:

Create Whoami Host

SSL can be configured as needed.

Add the following configuration in the Advanced tab to enable Tinyauth authentication:

Terminal window
# Root location
location / {
# Pass the request to the app
proxy_pass $forward_scheme://$server:$port;
# Add other app-specific config here
# Tinyauth auth request
auth_request /tinyauth;
error_page 401 = @tinyauth_login;
}
# Tinyauth auth request
location /tinyauth {
# Pass request to Tinyauth
proxy_pass http://tinyauth:3000/api/auth/nginx;
# Pass the request headers
proxy_set_header x-forwarded-proto $scheme;
proxy_set_header x-forwarded-host $http_host;
proxy_set_header x-forwarded-uri $request_uri;
}
# Tinyauth login redirect
location @tinyauth_login {
return 302 http://tinyauth.example.com/login?redirect_uri=$scheme://$http_host$request_uri; # Replace with your app URL
}

It should look like this:

Whoami Host Advanced

Save the host configuration. Accessing the protected host will redirect to the Tinyauth login page if not already logged in. Repeat this process for each host to be protected by Tinyauth.