Passing original incoming IP through Cloudflare to NPM? #5597
Replies: 1 comment
|
The 403 makes sense with that combination.
I would separate the two controls:
real_ip_header CF-Connecting-IP;
real_ip_recursive on;This allows Mastodon to receive the visitor’s real IP while the network layer prevents direct access to the origin. The important security detail is that You can verify the protection by testing both paths: # Through Cloudflare — should succeed
curl -I https://mastodon.example.com
# Directly to the origin — should be blocked
curl --resolve mastodon.example.com:443:ORIGIN_IP \
https://mastodon.example.com/This also appears related to the current NPM Access List/real-IP limitation tracked in #5374, so I don’t think you are missing an Access List setting. |
Uh oh!
There was an error while loading. Please reload this page.
I'm self-hosting a Mastodon server behind Cloudflare and trying to configure NPM so that I can pass a visitor's original (non-Cloudflare) IP address through to Mastodon.
All my other domains are configured in NPM using an Access List set up to only accept Cloudflare IP addresses. That works great for all of those sites, but in the interest of properly federating my Mastodon instance, I need to be able to see the actual IP addresses coming in.
Currently I have the Cloudflare Access List disabled, with Access set to "Public."
In the Custom Nginx Configuration field of the Proxy Host I have the following code:
That list of IPs are all the possible Cloudflare IPs. The
CF-Connecting-IPis the original visitor IP address, prior to Cloudflare.This setup is working, and Mastodon logs the correct external IP addresses, but unfortunately this setup still leaves the Access List as "Public" rather than narrowed down specifically to my pre-existing Cloudflare list.
If I turn the Cloudflare Access List back on, I get a 403 Forbidden error from Openresty in the browser unless I also delete the
real_ip_header CF-Connecting-IP;line.Any ideas about what I can change in my configuration in order to be able to use the Access List within NPM while still receiving the real external IP addresses of visitors?
All reactions