mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
31 lines
678 B
Plaintext
31 lines
678 B
Plaintext
client_max_body_size 1G;
|
|
|
|
location ~ %API_URI% {
|
|
|
|
rewrite_by_lua_block {
|
|
|
|
local api = require "api"
|
|
local api_whitelist_ip = { %API_WHITELIST_IP% }
|
|
local api_uri = "%API_URI%"
|
|
local logger = require "logger"
|
|
|
|
if api.is_api_call(api_uri, api_whitelist_ip) then
|
|
ngx.header.content_type = 'text/plain'
|
|
if api.do_api_call(api_uri) then
|
|
logger.log(ngx.NOTICE, "API", "API call " .. ngx.var.request_uri .. " successfull from " .. ngx.var.remote_addr)
|
|
ngx.print("ok")
|
|
else
|
|
logger.log(ngx.WARN, "API", "API call " .. ngx.var.request_uri .. " failed from " .. ngx.var.remote_addr)
|
|
ngx.print("ko")
|
|
end
|
|
|
|
ngx.exit(ngx.HTTP_OK)
|
|
|
|
end
|
|
|
|
ngx.exit(ngx.OK)
|
|
}
|
|
|
|
}
|
|
|