Our architecture now uses CloudFront, which proxies to Elastic Load Balancer, which proxies to our application server. In the process, our x-forwarded-for headers, which we formerly relied on, are getting longer.
Assume a client IP address of 1.2.3.4. In the past, when it was just nginx forwarding to gunicorn, the header might look like:
We'd grab that and be all good. Now, with Cloudfront (IP: 2.3.4.5) and ELB (IP: 3.4.5.6), we get something closer to:
x-forwarded-for: 1.2.3.4, 2.3.4.5
Alas, Django Ratelimit has no ambition of doing good things with this, and since we have many Cloudfront termination points and many ELBs, we can't use the X-forward-for keys like we used to, and they fail open, meaning that they don't do anything anymore.
Our architecture now uses CloudFront, which proxies to Elastic Load Balancer, which proxies to our application server. In the process, our
x-forwarded-forheaders, which we formerly relied on, are getting longer.Assume a client IP address of 1.2.3.4. In the past, when it was just nginx forwarding to gunicorn, the header might look like:
We'd grab that and be all good. Now, with Cloudfront (IP: 2.3.4.5) and ELB (IP: 3.4.5.6), we get something closer to:
Alas, Django Ratelimit has no ambition of doing good things with this, and since we have many Cloudfront termination points and many ELBs, we can't use the X-forward-for keys like we used to, and they fail open, meaning that they don't do anything anymore.