From 79f532b5c05736f888ed4907cd2b0c6313d68184 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 30 Oct 2022 14:19:44 +0000 Subject: [PATCH] Do a lookup to find reverse proxy `forwarded_allow_ips` doesn't support CIDR --- etc/gunicorn.conf.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/etc/gunicorn.conf.py b/etc/gunicorn.conf.py index 5ffd42e..9200723 100644 --- a/etc/gunicorn.conf.py +++ b/etc/gunicorn.conf.py @@ -1,4 +1,4 @@ -import os +import socket import gunicorn @@ -16,6 +16,9 @@ threads = 2 # Replace gunicorn's 'Server' HTTP header gunicorn.SERVER_SOFTWARE = gunicorn.SERVER = "Wouldn't you like to know" -# Allow `X-Forwarded-*` headers from specific IPs -if "FORWARDED_ALLOW_IPS" in os.environ: - forwarded_allow_ips = os.environ["FORWARDED_ALLOW_IPS"] +# HACK: Allow traefik to send forwarded IPs +# CIDR isn't supported here sadly +try: + forwarded_allow_ips = socket.gethostbyname("traefik") +except socket.gaierror: + pass