|
| 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 | +``` |
0 commit comments