From d43b82b757234e4363f0bbbd50544465b551d106 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 24 Oct 2021 18:24:10 +0200 Subject: [PATCH] remote API - only do action if 403 --- confs/site/log-lua.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/confs/site/log-lua.conf b/confs/site/log-lua.conf index a587b32..c4123c2 100644 --- a/confs/site/log-lua.conf +++ b/confs/site/log-lua.conf @@ -23,7 +23,7 @@ local use_remote_api = {% if USE_REMOTE_API == "yes" %}true{% else %} local remoteapi = require "remoteapi" local iputils = require "resty.iputils" -if use_remote_api and not iputils.ip_in_cidrs(ngx.var.remote_addr, cjson.decode(ngx.shared.reserved_ips:get("data"))) and ngx.shared.remote_api:get("id") ~= "empty" then +if use_remote_api and ngx.status == ngx.HTTP_FORBIDDEN and not iputils.ip_in_cidrs(ngx.var.remote_addr, cjson.decode(ngx.shared.reserved_ips:get("data"))) and ngx.shared.remote_api:get("id") ~= "empty" then if ngx.shared.remote_api:get("ping") == "ko" then if remoteapi.ping2() then ngx.shared.remote_api:set("ping", "ok", 0) @@ -32,7 +32,7 @@ if use_remote_api and not iputils.ip_in_cidrs(ngx.var.remote_addr, cjson.decode( logger.log(ngx.ERR, "REMOTE API", "Can't contact the remote API, feature will be disabled") end end - if ngx.shared.remote_api:get("ping") ~= "ko" and ngx.status == ngx.HTTP_FORBIDDEN then + if ngx.shared.remote_api:get("ping") ~= "ko" then local reason = "other" if use_bad_behavior and new_bad_behavior_ban then reason = "behavior"