-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.conf
49 lines (39 loc) · 1.7 KB
/
main.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
lua_shared_dict moesif_conf 2m;
init_by_lua_block {
local config = ngx.shared.moesif_conf;
config:set("application_id", os.getenv("MOESIF_APPLICATION_ID"))
jwt_secret = os.getenv("JWT_SECRET")
local mo_client = require "moesifapi.lua.moesif_client"
mo_client.get_moesif_client(ngx)
}
lua_package_path "/usr/local/share/lua/5.1/lua/resty/moesif/?.lua;;";
server {
listen 80;
resolver 8.8.8.8;
# Customer identity variables that Moesif will read downstream
set $moesif_user_id nil;
set $moesif_company_id nil;
# Request/Response body variable that Moesif will use downstream
set $moesif_res_body nil;
set $moesif_req_body nil;
# Optionally, identify the user and the company (account)
# from a request or response header, query param, NGINX var, etc
header_filter_by_lua_block {
ngx.var.moesif_user_id = ngx.req.get_headers()["User-Id"]
ngx.var.moesif_company_id = ngx.req.get_headers()["Company-Id"]
}
access_by_lua_file /usr/local/share/lua/5.1/lua/resty/moesif/read_req_body.lua;
body_filter_by_lua_file /usr/local/share/lua/5.1/lua/resty/moesif/read_res_body.lua;
log_by_lua_file /usr/local/share/lua/5.1/lua/resty/moesif/send_event.lua;
# Sample Hello World API
location /api {
access_by_lua_file /etc/nginx/conf.d/jwt_verification.lua;
proxy_pass http://127.0.0.1:80/hello;
}
# If you intend to skip logging api call for specific location context, you could use - `set $moesif_log_event false;`.
# For more reference refer to - https://github.com/Moesif/lua-resty-moesif#moesif_log_event
location /hello {
add_header Content-Type "application/json";
return 200 '{\r\n \"message\": \"Hello World\",\r\n \"completed\": true\r\n}';
}
}