-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathREADME
76 lines (56 loc) · 1.74 KB
/
README
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
ABOUT:
------
ngx_coolkit is collection of small and useful nginx add-ons.
CONFIGURATION DIRECTIVES:
-------------------------
override_method off | [methods] source (context: http, server, location)
------------------------------------------------------------------------
Override HTTP method.
default: none
CONFIGURATION VARIABLES:
------------------------
$remote_passwd
-----------------
Decoded password from "Authorization" header (Basic HTTP Authentication).
$location
---------
Name of the matched location block.
EXAMPLE CONFIGURATION #1:
-------------------------
http {
server {
location / {
override_method $arg_method;
proxy_pass http://127.0.0.1:8100;
}
}
}
Pass request with changed HTTP method (based on "?method=XXX") to the backend.
EXAMPLE CONFIGURATION #2:
-------------------------
http {
upstream database {
postgres_server 127.0.0.1 dbname=test
user=monty password=some_pass;
}
server {
location = /auth {
internal;
set_quote_sql_str $user $remote_user;
set_quote_sql_str $pass $remote_passwd;
postgres_pass database;
postgres_query "SELECT login FROM users WHERE login=$user AND pass=$pass";
postgres_rewrite no_rows 403;
postgres_output none;
}
location / {
auth_request /auth;
root /files;
}
}
}
Restrict access to local files by authenticating against SQL database.
Required modules (other than ngx_coolkit):
- ngx_http_auth_request_module,
- ngx_postgres (PostgreSQL) or ngx_drizzle (MySQL, Drizzle, SQLite),
- ngx_set_misc.