forked from ory/awesome-ory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
79 lines (65 loc) · 1.99 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
events {
worker_connections 1024;
}
http {
resolver 127.0.0.11 valid=10s;
upstream public_api {
server hydra:4444;
server hydra:4444; # We can load balance the traffic to support scaling
}
upstream admin_api {
server hydra:4445;
server hydra:4445;
}
upstream token_api {
server hydra:5555;
server hydra:5555;
}
upstream consent {
server consent:3000;
server consent:3000;
}
server {
listen 80;
location ~ ^/(.well-known|oauth2/auth|oauth2/token|oauth2/revoke|oauth2/fallbacks/consent|oauth2/fallbacks/error|userinfo)/? {
proxy_pass http://public_api;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
}
location ~* /(consent|login|logout) {
proxy_pass http://consent;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
}
location ~ ^/(clients|keys|health|metrics|version|oauth2/auth/requests|oauth2/introspect|oauth2/flush)/? {
set $allow 0;
if ($remote_addr ~* "172.28.0.*") {
set $allow 1;
}
if ($arg_secret = "GuQ8alL2") {
set $allow 1;
}
if ($allow = 0) {
return 403;
}
rewrite /admin/(.*) /$1 break;
proxy_pass http://admin_api;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
}
error_page 401 = @error401;
# Catch if 401/unauthorized and redirect for login
location @error401 {
return 302 http://127.0.0.1:4455/login?next=http://$http_host;
}
}
}