fix: trust docker gateway IP for reverse proxy auth
Deploy Dashboard / deploy (push) Successful in 1m35s

This commit is contained in:
Gan, Jimmy
2026-02-27 23:48:34 +08:00
parent 3888a57642
commit a0354c335b
4 changed files with 26 additions and 4 deletions
+19
View File
@@ -60,3 +60,22 @@ def is_lan_ip(ip_str: str) -> bool:
return False
except ValueError:
return False
TRUSTED_PROXIES = os.environ.get("TRUSTED_PROXIES", "127.0.0.1,::1,172.16.0.0/12,10.0.0.0/8").split(",")
def is_trusted_proxy(ip_str: str) -> bool:
import ipaddress
try:
ip_obj = ipaddress.ip_address(ip_str)
for subnet_str in TRUSTED_PROXIES:
subnet_str = subnet_str.strip()
if "/" in subnet_str:
if ip_obj in ipaddress.ip_network(subnet_str):
return True
else:
if ip_obj == ipaddress.ip_address(subnet_str):
return True
return False
except ValueError:
return False