NginxProxyManager / NginxProxyManager/nginx-proxy-manager
X-forwared-for shows Cloudflare IP instead of real IP
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 34.2k
- Forks
- 3.9k
- Avg merge
- 21h 12m
- Merged PRs (30d)
- 20
Description
Checklist
- Have you pulled and found the error with
jc21/nginx-proxy-manager:latestdocker image?- Yes
- Are you sure you're not using someone else's docker image?
- Yes
- Have you searched for similar issues (both open and closed)?
- Yes
Describe the bug
When using Cloudflare infront of NPM, NPM populates the X-forwarded-for header with the cloudflare IP instead of the real IP that cloudflare provices in its X-forwarded-for header. I would expect NPM to check if the source IP is one of cloudflare's and trust the X-forwarded-for header in that case. This seemd to be a feature in 2.6.0 but broken in all verisons afterwards.
Nginx Proxy Manager Version
2.9.8
To Reproduce
Set up a cloudflare domain and let it point to NPM. If you now navigate to the site the server behind NPM will get one of cloudflare's IPs as the X-forwarded-for header instead of the client IP
Expected behavior
Show the real client IP that cloudflare reports in the X-forwarded-for header.
Operating System
Synology NAS
Additional context
The closed issues #112 and #811 both suggest using the following settings as a workaround:
real_ip_header CF-Connecting-IP;
#real_ip_header X-Forwarded-For;
This is however a major security risk as it doesnt check if the request is actually coming from cloudflare. It allows anyone with knowledge of your IP to send requests pretending to be from cloudflare with an CF-Connecting-IP header set to any IP they want, (including lan ips such as 10.0.0.1) possibly circumventing any IP based security measures.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the setup with Cloudflare in front of Nginx Proxy Manager and inspect how proxy headers are configured and populated. Verify the source is checked against Cloudflare before trusting its X-forwarded-for header, and confirm that direct clients cannot spoof the reported address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nginx
- Domain
- networking, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100