plugins/mod_http.lua
changeset 13129 90394be5e6a5
parent 13111 9c4dc1e6d2c9
child 13130 d043834f15d2
--- a/plugins/mod_http.lua	Sat Jun 03 16:15:52 2023 +0200
+++ b/plugins/mod_http.lua	Sat Jun 03 17:10:12 2023 +0200
@@ -297,7 +297,13 @@
 
 local trusted_proxies = module:get_option_set("trusted_proxies", { "127.0.0.1", "::1" })._items;
 
+--- deal with [ipv6]:port / ip:port format
+local function normal_ip(ip)
+	return ip:match("^%[([%x:]*)%]") or ip:match("^([%d.]+)") or ip;
+end
+
 local function is_trusted_proxy(ip)
+	ip = normal_ip(ip);
 	if trusted_proxies[ip] then
 		return true;
 	end