Skip to content

Commit 443143c

Browse files
committed
Updated conf
1 parent ec5c8ed commit 443143c

File tree

3 files changed

+81
-89
lines changed

3 files changed

+81
-89
lines changed

conf/app.example.conf

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1+
# Basic configuration
12
appname = nginx-http-auth
3+
httpaddr = 127.0.0.1
24
httpport = 8080
3-
runmode = dev
5+
runmode = dev # Use "prod" for production environment or "test" for test environment
46

5-
# Session
6-
sessionon = true
7+
# Session configuration
78
sessionname = SessionID
89
sessiongcmaxlifetime = 86400
910
sessioncookielifetime = 86400
1011
sessionprovider = redis
1112
sessionproviderconfig = "127.0.0.1:6379"
1213

1314

14-
# XSRF
15-
enablexsrf = true
15+
# XSRF configuration
1616
xsrfkey = 4b6774f328ee1a2f24fcb62842fc0cfc
1717
xsrfexpire = 86400
1818

19-
19+
# User authentication login interface
2020
authAPI = http://127.0.0.1:5000/api/login
21+
22+
# The users who can access control API
2123
controlUsers = admin;iTraceur;zhaowencheng
2224

25+
# Client IP control configuration
2326
[ipControl]
24-
deny =
2527
direct = 127.0.0.1;192.168.1.5
28+
deny =
2629

30+
# Time range control configuration
2731
[timeControl]
28-
deny =
2932
direct =
33+
deny = 00:00-08:00;21:00-23:59
3034

35+
# User control configuration
3136
[userControl]
32-
deny = test;
3337
allow =
38+
deny = test;demo

conf/nginx.conf

Lines changed: 0 additions & 80 deletions
This file was deleted.

conf/nginx.example.conf

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
proxy_cache_path cache/ keys_zone=auth_cache:10m;
2+
proxy_headers_hash_max_size 512;
3+
proxy_headers_hash_bucket_size 128;
4+
5+
upstream protected-backend {
6+
server 127.0.0.1:8000;
7+
}
8+
9+
upstream auth-backend {
10+
server 127.0.0.1:8080;
11+
}
12+
13+
server {
14+
listen 80;
15+
16+
location / {
17+
auth_request /auth-proxy;
18+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19+
proxy_set_header Host $http_host;
20+
21+
error_page 401 =200 @error401;
22+
23+
proxy_pass http://protected-backend;
24+
}
25+
26+
location @error401 {
27+
return 302 /passport/login?target=$request_uri;
28+
}
29+
30+
location = /auth-proxy {
31+
internal;
32+
33+
proxy_pass http://auth-backend/auth-proxy;
34+
proxy_pass_request_body off;
35+
proxy_set_header Content-Length "";
36+
proxy_set_header X-CookieName "SessionID";
37+
proxy_set_header Cookie SessionID=$cookie_SessionID;
38+
39+
proxy_cache auth_cache;
40+
proxy_cache_valid 200 10m;
41+
proxy_cache_key "$http_authorization$cookie_SessionID";
42+
}
43+
44+
location /passport/login {
45+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
46+
proxy_set_header Host $http_host;
47+
proxy_pass http://auth-backend/passport/login;
48+
}
49+
50+
location /passport/logout {
51+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
52+
proxy_set_header Host $http_host;
53+
proxy_pass http://auth-backend/passport/logout;
54+
}
55+
56+
location /captcha {
57+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
58+
proxy_set_header Host $http_host;
59+
proxy_pass http://auth-backend/captcha;
60+
}
61+
62+
location /static {
63+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
64+
proxy_set_header Host $http_host;
65+
proxy_pass http://auth-backend/static;
66+
}
67+
}

0 commit comments

Comments
 (0)