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 support for trusting X-Forwarded-For header to get client IP #921

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

Skyler84
Copy link
Contributor

@Skyler84 Skyler84 commented Nov 13, 2023

This fixes #882
falls back to remote ip if header unavailable

Added trust_x_forwarded_headers option in warpgate.yaml config

http:
  enable: true
  listen: "0.0.0.0:8888"
  certificate: "./data/tls.certificate.pem"
  key: "./data/tls.key.pem"
  trust_x_forwarded_headers: false

falls back to remote ip if header unavailable
@Eugeny
Copy link
Member

Eugeny commented Nov 13, 2023

Thanks! Would you consider adding support for X-Forwarded-Proto in the same PR to cover both bases?

@Skyler84
Copy link
Contributor Author

Skyler84 commented Nov 13, 2023

Sure thing, what do you think the X-Forward-Proto should affect. I noticed that there should be support for x-forwarded-... already but it's all lowercase, but i'm not sure how well this will work as some proxies use X-Forwarded-... with upper case words etc

@Eugeny
Copy link
Member

Eugeny commented Nov 13, 2023

It's used to construct external URLs for SSO and SSH 2FA. The case doesn't matter because header name matching in both http and poetry is case insensitive.

@Skyler84
Copy link
Contributor Author

Skyler84 commented Nov 13, 2023

header name matching in both http and poetry is case insensitive

Ah perfect, I should be able to work on that just fine then. I'll update my bits to use the static header string declarations!

@Skyler84
Copy link
Contributor Author

This works quite nicely now, have tested running behind traefik with multiple hostnames, ports and http/https and the SSO redirect works perfectly. Tested with SSH SSO as well and appears to be working

@Eugeny
Copy link
Member

Eugeny commented Nov 16, 2023

I've reordered things slightly for readability ✌️

Thanks!

@Eugeny Eugeny merged commit f55fcc3 into warp-tech:main Nov 16, 2023
5 of 7 checks passed
@Skyler84 Skyler84 deleted the x-forward-header branch November 16, 2023 19:16
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.

Accept X-Forwarded-For from a proxy in front of Warpgate
2 participants