Skip to content

Commit 504b2c1

Browse files
committed
feat: add tinyauth behind proxy config
1 parent b080ed6 commit 504b2c1

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

docs/advanced.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,48 @@ When using `network_mode: host` in docker alongside with traefik, the `redirect_
77
```yaml
88
entryPoints:
99
web:
10-
address: ":80"
1110
forwardedHeaders:
1211
trustedIPs:
13-
- "127.0.0.1/32"
14-
- "172.16.0.0/12"
12+
- 127.0.0.1/32
13+
- 172.16.0.0/12
1514
```
1615
1716
Or by using the following CLI arguments:
1817
1918
```shellscript
20-
--entryPoints.web.address=:80
2119
--entryPoints.web.forwardedHeaders.trustedIPs=127.0.0.1/32,172.16.0.0/12
2220
```
2321

2422
_See issue [#35](https://github.com/steveiliop56/tinyauth/issues/35) by [Aleksey](https://github.com/liveder)_
23+
24+
## Tinyauth behind proxy
25+
26+
In some environments you may need to use tinyauth in another proxy and to do this securely you may have to expose it. For example you may have tinyauth on `tinyauth.mydomain.com` and try to use the middleware from another proxy using `http://tinyauth.mydomain.com/api/auth/traefik`.
27+
28+
In this case traefik will not respect the `X-Forwarded-*` headers meaning that the `redirect_uri` in tinyauth will always point to tinyauth's domain (so `tinyauth.mydomain.com`) instead of the app's domain. To fix this, you can tell traefik to trust the headers. If your setup looks like the following:
29+
30+
```mermaid
31+
flowchart LR
32+
user["User"] --> proxy1["Proxy 1 (10.0.0.2)"]
33+
proxy1 --> tinyauthExposed["Tinyauth (tinyauth.mydomain.om)"]
34+
tinyauthExposed --> proxy2["Proxy 2 (10.0.0.3)"]
35+
proxy2 --> tinyauth["Tinyauth"]
36+
```
37+
38+
You can tell proxy 2 to trust headers from proxy 1 with the following configuration:
39+
40+
```yaml
41+
entryPoints:
42+
web:
43+
forwardedHeaders:
44+
trustedIPs:
45+
- 10.0.0.2
46+
```
47+
48+
You can also configure it through CLI options:
49+
50+
```shellscript
51+
--entryPoints.web.forwardedHeaders.trustedIPs=10.0.0.2
52+
```
53+
54+
_See issue [#134](https://github.com/steveiliop56/tinyauth/issues/134#issuecomment-2848793841) by [@eliasbenb](https://github.com/eliasbenb)_

0 commit comments

Comments
 (0)