From f1c952e87b20df2b5a63ef9ac5a502029385aea0 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 16 Feb 2021 16:29:01 +0100 Subject: [PATCH] add registry tracking --- docker/nginx/conf.d/client.conf | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docker/nginx/conf.d/client.conf b/docker/nginx/conf.d/client.conf index 9f11afd8..a373c94a 100644 --- a/docker/nginx/conf.d/client.conf +++ b/docker/nginx/conf.d/client.conf @@ -277,6 +277,23 @@ server { 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; + + # register the registry access in accounts service (cookies should contain jwt) + log_by_lua_block { + if ngx.status == ngx.HTTP_OK or ngx.status == ngx.HTTP_NOT_FOUND then + local http = require("socket.http") + local headers = { Cookie = ngx.req.get_headers()["Cookie"] } + local method = ngx.req.get_method() == ngx.HTTP_GET and "read" or "write" + local ok, statusCode, headers, statusText = http.request { + url = "http://accounts:3000/track/registry/" .. method, + method = "POST", + headers = headers + } + if statusCode ~= ngx.HTTP_NO_CONTENT then + ngx.log(ngx.ERR, "accounts endpoint /track/registry/" .. method .. " failed with error " .. statusCode) + end + end + } } location /skynet/skyfile {