From 1023c821abe8a1e78c1b5d97888f731609e48d20 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 30 Oct 2022 12:14:16 +0000 Subject: [PATCH] Allow gunicorn to use `X-Forwarded-*` header --- etc/gunicorn.conf.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/gunicorn.conf.py b/etc/gunicorn.conf.py index 27493f1..5ffd42e 100644 --- a/etc/gunicorn.conf.py +++ b/etc/gunicorn.conf.py @@ -1,3 +1,5 @@ +import os + import gunicorn wsgi_app = "website.wsgi:application" @@ -13,3 +15,7 @@ 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"]