📒 docs: improve clarity for ProxyHeader and TrustProxy configuration#4140
📒 docs: improve clarity for ProxyHeader and TrustProxy configuration#4140ReneWerner87 merged 14 commits intomainfrom
Conversation
- Updated c.IP() documentation in docs/api/ctx.md with clear explanation that both TrustProxy and ProxyHeader must be configured - Added comprehensive examples showing proper reverse proxy setup - Enhanced ProxyHeader, TrustProxy, and TrustProxyConfig descriptions in docs/api/fiber.md with security warnings - Added new "Getting the Real Client IP Address" section to docs/guide/reverse-proxy.md with complete examples - Included table of common proxy headers and configuration testing example - All markdown linting checks pass This addresses the confusion reported in the issue where users set ProxyHeader but didn't realize TrustProxy was also required. Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Improves Fiber documentation to clarify how to correctly configure ProxyHeader, TrustProxy, and TrustProxyConfig so c.IP() can return the real client IP when running behind reverse proxies (addressing #4139).
Changes:
- Expanded reverse-proxy guide with a new “Getting the Real Client IP Address” section, examples, and a debugging endpoint.
- Updated
fiber.Configdocs to clarifyProxyHeader/TrustProxydependencies and add stronger security guidance. - Updated
c.IP()docs with an info box and concrete configuration examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| docs/guide/reverse-proxy.md | Adds an end-to-end guide for real client IP extraction behind proxies, including security warning and examples. |
| docs/api/fiber.md | Clarifies ProxyHeader, TrustProxy, and TrustProxyConfig configuration and security implications in the config reference table. |
| docs/api/ctx.md | Updates c.IP() documentation with an admonition and working reverse-proxy configurations. |
|
@copilot apply changes based on the comments in this thread |
Applied all three changes in commit
|
|
@copilot try again |
The three changes are applied in commit |
|
@claude[agent] Apply the suggestions raised on this pull request |
There was a problem hiding this comment.
Pull request overview
Updates Fiber v3 documentation to clarify how to correctly obtain the real client IP (c.IP()) when running behind a reverse proxy, emphasizing the required combination of TrustProxy, ProxyHeader, and a properly configured TrustProxyConfig, plus related security considerations.
Changes:
- Clarifies
ProxyHeader,TrustProxy, andTrustProxyConfigbehavior and security warnings in the Fiber config reference. - Expands the reverse proxy guide with a dedicated “real client IP” section, examples, and header recommendations for common providers.
- Updates the v3 migration guide (“What’s New”) and
c.IP()API docs to highlight required proxy configuration and link to the reverse proxy guide.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| docs/whats_new.md | Adds migration guidance emphasizing TrustProxy + ProxyHeader for c.IP() and links to reverse proxy docs. |
| docs/guide/reverse-proxy.md | Adds a comprehensive section on configuring Fiber to read real client IPs behind proxies, with examples and security warning. |
| docs/api/fiber.md | Improves config reference entries for ProxyHeader, TrustProxy, and TrustProxyConfig (dependencies, behavior, security). |
| docs/api/ctx.md | Enhances c.IP() documentation with an info box and concrete reverse-proxy configuration examples. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Fiber v3 documentation to clarify how ProxyHeader, TrustProxy, and TrustProxyConfig work together so users behind reverse proxies can correctly obtain the real client IP via c.IP() (and understand the related security implications).
Changes:
- Clarifies that
ProxyHeaderonly affectsc.IP()whenTrustProxyis enabled and the proxy is trusted viaTrustProxyConfig. - Expands reverse-proxy guidance with configuration examples, common header mappings, and a verification/debugging snippet.
- Updates v3 migration notes to highlight the required
ProxyHeadersetting when upgrading.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/whats_new.md | Adds migration guidance emphasizing TrustProxy + ProxyHeader for c.IP() behind proxies. |
| docs/guide/reverse-proxy.md | Adds a dedicated “real client IP” section with examples, security warning, and troubleshooting guidance. |
| docs/api/fiber.md | Refines config reference entries for ProxyHeader, TrustProxy, and TrustProxyConfig (behavior + security). |
| docs/api/ctx.md | Updates c.IP() docs with an info box and concrete proxy configuration examples. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates Fiber v3 documentation to reduce confusion when running behind reverse proxies, specifically clarifying that c.IP() will not read proxy headers unless TrustProxy and TrustProxyConfig are configured alongside ProxyHeader.
Changes:
- Clarifies
ProxyHeader’s dependency onTrustProxy+TrustProxyConfigand adds security guidance about header spoofing. - Adds a dedicated “real client IP” setup section (with examples and a debugging endpoint) to the reverse proxy guide.
- Updates the v3 migration notes to explicitly call out the
ProxyHeaderrequirement and links to the reverse proxy guide.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/whats_new.md | Adds an explicit migration note that ProxyHeader must be set (in addition to the TrustProxy changes) and links to the reverse proxy guide. |
| docs/guide/reverse-proxy.md | Adds a new section documenting how to correctly get the real client IP behind a proxy, including examples and security warning. |
| docs/api/fiber.md | Expands config reference docs for ProxyHeader, TrustProxy, and TrustProxyConfig (including corrected c.Scheme() vs c.Protocol() mention). |
| docs/api/ctx.md | Enhances c.IP() docs with an info box + concrete configuration examples and cross-references. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Documentation-focused update to clarify how Fiber’s reverse-proxy settings (TrustProxy, ProxyHeader, TrustProxyConfig) affect c.IP() and related behavior, targeting common v2→v3 upgrade confusion behind proxies.
Changes:
- Clarifies that
ProxyHeaderonly affectsc.IP()whenTrustProxyis enabled and the proxy is trusted viaTrustProxyConfig. - Expands the reverse-proxy guide with a dedicated “real client IP” setup section, examples, and security warnings.
- Updates the v3 migration guide and config reference docs to reflect correct proxy-header behavior and defaults.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| docs/whats_new.md | Adds migration notes/examples emphasizing ProxyHeader usage alongside trusted proxy settings. |
| docs/guide/reverse-proxy.md | Adds a comprehensive “real client IP” configuration section with examples and warnings. |
| docs/api/fiber.md | Expands config reference entries for ProxyHeader, TrustProxy, and TrustProxyConfig with clearer behavior/security notes. |
| docs/api/ctx.md | Improves c.IP() docs with an info box and concrete configuration examples for reverse proxies. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Fiber’s documentation to clarify how ProxyHeader, TrustProxy, and TrustProxyConfig must be configured together for c.IP() to return a client IP when running behind a reverse proxy, improving v2→v3 upgrade guidance and reducing misconfiguration risk.
Changes:
- Clarifies that
ProxyHeaderalone is insufficient;TrustProxy+ trusted proxies (TrustProxyConfig) are required for proxy headers to be honored. - Expands reverse proxy guidance with configuration examples, common header options, and debugging tips.
- Updates migration docs to highlight the required proxy configuration and link to the reverse-proxy guide.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/whats_new.md | Strengthens v3 migration notes and examples for trusted proxy + ProxyHeader configuration. |
| docs/guide/reverse-proxy.md | Adds a dedicated “real client IP” section with setup guidance and examples. |
| docs/api/fiber.md | Expands config reference entries for ProxyHeader, TrustProxy, and TrustProxyConfig (including security notes). |
| docs/api/ctx.md | Improves c.IP() docs with an info box and concrete reverse-proxy configuration examples. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Description
Users upgrading from v2 to v3 or deploying behind reverse proxies encounter
c.IP()returning the proxy's IP instead of the client's real IP fromX-Forwarded-For. The issue stems from unclear documentation: settingProxyHeaderalone has no effect—bothTrustProxyandTrustProxyConfigmust also be configured.Changes introduced
Documentation Update: Enhanced four documentation files to clarify the proxy configuration requirements:
docs/api/ctx.md -
c.IP()method documentation:TrustProxyandProxyHeaderare requireddocs/api/fiber.md - Configuration reference table:
ProxyHeader: Clarified dependency onTrustProxy, added security warning about header spoofing, listed common header valuesTrustProxy: Detailed behavior when enabled/disabled, explained validation mechanism, corrected documentation to referencec.Scheme()instead ofc.Protocol()forX-Forwarded-Protoheader handlingTrustProxyConfig: Documented all fields (Proxies,Loopback,Private,LinkLocal,UnixSocket) with concrete examples, corrected default value fromnilto{}(empty struct)docs/guide/reverse-proxy.md:
docs/whats_new.md - v3 migration guide:
TrustProxyandProxyHeadermust be configured togetherProxyHeader: fiber.HeaderXForwardedForto the migration example codeProxyHeaderrequirementExamples:
Type of change
Checklist
/docs/directory for Fiber's documentation.Original prompt