24 lines
862 B
Plaintext
24 lines
862 B
Plaintext
|
include /etc/nginx/conf.d/include/cors;
|
||
|
include /etc/nginx/conf.d/include/sia-auth;
|
||
|
include /etc/nginx/conf.d/include/track-registry;
|
||
|
|
||
|
limit_req zone=registry_access_by_ip burst=600 nodelay;
|
||
|
limit_req zone=registry_access_by_ip_throttled burst=200 nodelay;
|
||
|
|
||
|
proxy_set_header User-Agent: Sia-Agent;
|
||
|
proxy_read_timeout 600; # siad should timeout with 404 after 5 minutes
|
||
|
proxy_pass http://siad/skynet/registry;
|
||
|
|
||
|
access_by_lua_block {
|
||
|
-- this block runs only when accounts are enabled
|
||
|
if os.getenv("ACCOUNTS_ENABLED") ~= "true" then return end
|
||
|
|
||
|
local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true })
|
||
|
if res.status == ngx.HTTP_OK then
|
||
|
local json = require('cjson')
|
||
|
local limits = json.decode(res.body)
|
||
|
if limits.registry > 0 then
|
||
|
ngx.sleep(limits.registry / 1000)
|
||
|
end
|
||
|
end
|
||
|
}
|