Skip to content

Commit ad2320f

Browse files
committed
refactor: update nginx proxy manager instructions
1 parent 8f6322f commit ad2320f

2 files changed

Lines changed: 8 additions & 27 deletions

File tree

-248 KB
Binary file not shown.

src/content/docs/docs/guides/nginx-proxy-manager.mdx

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ services:
2626
- npm-data:/data
2727
- npm-letsencrypt:/etc/letsencrypt
2828

29+
# Whoami is not required, but serves as a simple example app to demonstrate Tinyauth integration. You can replace it with any app of your choice.
2930
whoami:
3031
image: traefik/whoami:latest
3132
restart: unless-stopped
@@ -79,36 +80,31 @@ Add the following configuration in the Advanced tab to enable Tinyauth authentic
7980
# Root location
8081
location / {
8182
# Pass the request to the app
82-
proxy_pass $forward_scheme://$server:$port;
83+
proxy_pass http://whoami:80; # Replace with your app URL, e.g. http://10.10.10.25:80
8384

8485
# Add other app-specific config here
8586

8687
# Tinyauth auth request
8788
auth_request /tinyauth;
88-
error_page 401 = @tinyauth_login;
89+
auth_request_set $redirection_url $upstream_http_x_tinyauth_location;
90+
error_page 401 =302 $redirection_url;
8991
}
9092

9193
# Tinyauth auth request
9294
location /tinyauth {
93-
# Pass request to Tinyauth
95+
# Mark the location as internal to prevent direct access
96+
internal;
97+
98+
# Pass request to Tinyauth, do not use the Tinyauth domain here, use the internal Docker network name and port or the IP and port of the Tinyauth instance
9499
proxy_pass http://tinyauth:3000/api/auth/nginx;
95100

96101
# Pass the request headers
97102
proxy_set_header x-forwarded-proto $scheme;
98103
proxy_set_header x-forwarded-host $http_host;
99104
proxy_set_header x-forwarded-uri $request_uri;
100105
}
101-
102-
# Tinyauth login redirect
103-
location @tinyauth_login {
104-
return 302 http://tinyauth.example.com/login?redirect_uri=$scheme://$http_host$request_uri; # Replace with your app URL
105-
}
106106
```
107107

108-
It should look like this:
109-
110-
![Whoami Host Advanced](/screenshots/npm/whoami-advanced.png)
111-
112108
:::note
113109
The `/tinyauth` path can be renamed for convenience.
114110
:::
@@ -118,19 +114,4 @@ It should look like this:
118114
technologies like WebSockets.
119115
:::
120116

121-
:::note
122-
Due to the way Nginx handles forward auth, Tinyauth cannot automatically redirect to the unauthorized page. Thus, users may be redirected to a blank 403 Forbidden page in case of a failed authentication. This can be somehow mitigated by configuring a custom error page for the 403 status code:
123-
124-
```sh
125-
location / {
126-
# Rest of your configuration
127-
error_page 403 = @tinyauth_unauthorized;
128-
}
129-
130-
location @tinyauth_unauthorized {
131-
return 302 http://tinyauth.example.com/unauthorized?username=unavailable; # Replace with your app URL
132-
}
133-
```
134-
:::
135-
136117
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.

0 commit comments

Comments
 (0)