Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to allow running behind a reverse proxy with correct IP logging #4

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

pr0ton11
Copy link
Contributor

@pr0ton11 pr0ton11 commented Jun 6, 2024

What

This adds the necessary configuration for Fiber to run behind reverse proxy and log the correct IP address of the caller

Why

Whenever someone is running this behind a reverse proxy, only the reverse proxies IP is logged. This is not very helpful for analytics.

How

  • Added new configuration parameters (optional) to allow setting reverse proxy header and list of trusted proxies
  • Added the necessary configuration for Fiber to utilize this configuration and return the proper IP when calling ctx.IP() according to the documentation.

Small performance overhead gets generated by utilizing EnableIPValidation but this is a good way to ensure not returning spoofed, invalid IPs

@ryanolee
Copy link
Owner

ryanolee commented Jun 7, 2024

Thanks for raising this PR; will have a look this weekend! 👀
( I might add a new example in the examples dir with nginx configured just to confirm it works 🙌 )
I think the performance overhead is fine as you would have to set the option first anyway. Code looks good!

@ryanolee ryanolee merged commit 1b68656 into ryanolee:main Jun 7, 2024
@ryanolee
Copy link
Owner

ryanolee commented Jun 7, 2024

Awesome. Looks to work. Made a few minor changes in #5 to fix issues with config so that it would work and added an example to show it working with a trusted proxy configuration

@pr0ton11 pr0ton11 deleted the feature/add-reverse-proxy-support branch June 8, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants