Skip to content

Commit 40e544b

Browse files
committed
Added README
1 parent 8434519 commit 40e544b

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# nginx-http-auth
2+
3+
An authentication backend for the Nginx `ngx_http_auth_request_module` module.
4+
5+
[中文](https://github.com/iTraceur/nginx-http-auth/blob/main/README_CN.md)
6+
7+
## usage
8+
### Build from source
9+
```bash
10+
# git clone https://github.com/iTraceur/nginx-http-auth.git
11+
# go get ./...
12+
# chmod +x control
13+
# ./control build
14+
# ./control pack
15+
```
16+
17+
### Install
18+
```bash
19+
# tar -zxvf nginx-http-auth-0.1.0.tar.gz
20+
# cp conf/nginx.conf /etc/nginx/nginx.conf # and change it to suit your needs
21+
# mv conf/app.example.conf conf/app.conf # and change it to suit your needs
22+
# service nginx reload
23+
# ./control start
24+
```
25+
26+
### Configuration instructions
27+
```ini
28+
# Basic configuration
29+
appname = nginx-http-auth # App name
30+
httpaddr = 127.0.0.1 # HTTP listening address
31+
httpport = 8080 # HTTP listening port
32+
runmode = dev # Use "prod" for production environment or "test" for test environment
33+
34+
# Session configuration
35+
sessionname = SessionID # The name of the cookie that stored on the client
36+
sessiongcmaxlifetime = 86400 # Session expiration time
37+
sessioncookielifetime = 86400 # Cookie expiration time
38+
sessionprovider = redis # The provider of the session, you can also use memory, file, mysql, etc
39+
sessionproviderconfig = "127.0.0.1:6379" # The provider's path or link address
40+
41+
42+
# XSRF configuration
43+
xsrfkey = 4b6774f328ee1a2f24fcb62842fc0cfc # XSRF key
44+
xsrfexpire = 86400 # XSRF expiration time
45+
46+
# User remote authentication API
47+
authAPI = http://127.0.0.1:5000/api/login
48+
49+
# The users who can access control API, default admin
50+
controlUsers = admin;iTraceur;zhaowencheng
51+
52+
# Clinet IP control configuration
53+
[ipControl]
54+
direct = 127.0.0.1;192.168.1.5 # IPs that are allowed to access
55+
deny = # IPs that are denied to access, This configuration takes precedence over the direct
56+
57+
# Time control configuration
58+
[timeControl]
59+
direct = 09:00-21:00 # Time range that are denied to access
60+
deny = # Time range that are denied to access, This configuration takes precedence over the direct
61+
62+
# User control configuration
63+
[userControl]
64+
allow = # Users that are allowed to access, This configuration takes precedence over the deny
65+
deny = test;demo # Users that are denied to access
66+
```
67+
68+
### Nginx configuration
69+
```bash
70+
# cp conf/nginx.example.conf /etc/nginx/conf.d/nginx-http-auth.conf # and change it to suit your needs
71+
# service nginx reload
72+
```

README_CN.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# nginx-http-auth
2+
3+
一个用于Nginx `ngx_http_auth_request_module` 模块的认证后端。
4+
5+
## 安装使用
6+
### 从源码构建
7+
8+
```bash
9+
# git clone https://github.com/iTraceur/nginx-http-auth.git
10+
# go get ./...
11+
# chmod +x control
12+
# ./control build
13+
# ./control pack
14+
```
15+
16+
### 安装
17+
```bash
18+
# tar -zxvf nginx-http-auth-0.1.0.tar.gz
19+
# mv conf/app.example.conf conf/app.conf # 按需要更改相应的配置
20+
# ./control start
21+
```
22+
23+
### 配置说明
24+
```ini
25+
# 基本配置
26+
appname = nginx-http-auth
27+
httpaddr = 127.0.0.1 # HTTP 监听地址,按需要进行更改
28+
httpport = 8080 # HTTP 监听地址,按需要进行更改
29+
runmode = dev # 生产环境使用 prod,测试环境使用 test
30+
31+
# Session 配置
32+
sessionname = SessionID # 存储在客户端的 cookie 名称
33+
sessiongcmaxlifetime = 86400 # Session 过期时间
34+
sessioncookielifetime = 86400 # Cookie 过期时间
35+
sessionprovider = redis # Session 存储引擎, 还支持 memory, file, mysql 等
36+
sessionproviderconfig = "127.0.0.1:6379" # Session 存储引擎的路径或链接地址
37+
38+
39+
# XSRF 配置
40+
xsrfkey = 4b6774f328ee1a2f24fcb62842fc0cfc # XSRF key
41+
xsrfexpire = 86400 # XSRF 过期时间
42+
43+
# 远程用户认证接口
44+
authAPI = http://127.0.0.1:5000/api/login
45+
46+
# 可访问控制接口的用户,默认为admin
47+
controlUsers = admin;iTraceur;zhaowencheng
48+
49+
# 客户端 IP 访问控制
50+
[ipControl]
51+
direct = 127.0.0.1;192.168.1.5 # 允许访问的 IP
52+
deny = # 拒绝访问的IP,这个配置优先于 direct 的配置
53+
54+
# 访问时间段控制
55+
[timeControl]
56+
direct = 09:00-21:00 # 允许访问的时间段
57+
deny = # 拒绝访问的时间段,这个配置优先于 direct 的配置
58+
59+
# 用户访问控制
60+
[userControl]
61+
allow = # 允许访问的用户,这个配置优先于 deny 的配置
62+
deny = test;demo # 拒绝访问的用户
63+
```
64+
65+
### 配置Nginx
66+
```bash
67+
# cp conf/nginx.example.conf /etc/nginx/conf.d/nginx-http-auth.conf # 按需要更改相应的配置
68+
# service nginx reload
69+
```

0 commit comments

Comments
 (0)