I'm trying to get real client IP addresses from the X-Forwarded-For, X-Real-IP, or equivalent header.
Doing this securely requires configuring the CDN to authenticate to the backend, eg. client certificates like Cloudflare, or configuring the backend to trust those headers only when sent from a known IP range.
I'm attempting to do the second, but this requires a source of trusted IP ranges.
For Cloudflare, it's https://www.cloudflare.com/ips/
For Cloudfront, it's https://ip-ranges.amazonaws.com/ip-ranges.json
For AzureEdge, the nearest I can find is https://docs.microsoft.com/en-us/rest/api/cdn/edgenodes/edgenodes_list - but this is authenticated (which is annoying, but workable), and as I understand it, gives only the currently-active addresses for the account,
which change frequently. Depending on the frequency, this would require significant work to use.
https://www.microsoft.com/en-us/download/details.aspx?id=41653 has also been suggested repeatedly. This would be even more infuriating to use, as it is:
- Not scriptable, so must be updated manually
- Includes "compute" ranges, implying that anyone who rents an azure VPS will be included
Is there a plaintext or json list of all trusted IP ranges I can use for this? If not, is there another method of authentication available?