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

[TT-9985] add proxy protocol for http #5464

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

ldmonster
Copy link

@ldmonster ldmonster commented Aug 24, 2023

Ha proxy protocol handling added

Description

  • When creating HTTPS listener - create default http listener and upgrade it. Because of flow we need.
    Usually, flow looks like proxyproto.Listener -> tls.Listener -> net.Listener. Because of it - we have an early tls handshake and fail. Now, we have a middle wrap, like tls.Listener -> proxyproto.Listener -> net.Listener , and it works smooth.
  • Create helper functions to prevent repeating code
  • Add parameters to setRouter func to create proxy with "useProxyProtocol"
  • Add gateway config toggle named EnableProxyProtocolHTTP (HTTP because it toggle all kinds of HTTP traffic)

When i trying to upgrade listener in generateListener func - it throws error like "port is already in use". Because of it - listener upgrading now before HTTP server start.

Related Issue

#5463

Motivation and Context

With this feature we can use ha-proxy-protocol in our projects, with easy toggle from config file.

How This Has Been Tested

Tested in our infrastructure using ha-proxy to wrap request with tls, and sending to tyk.
Result: we have a new header "x-forwarded-for" with correct IP on the board.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring or add test (improvements in base code or adds test coverage to functionality)

Checklist

  • I ensured that the documentation is up to date
  • I explained why this PR updates go.mod in detail with reasoning why it's required
  • I would like a code coverage CI quality gate exception and have explained why

@lghiur lghiur changed the title add proxy protocol for http [TT-9985] add proxy protocol for http Sep 6, 2023
gateway/api_loader.go Outdated Show resolved Hide resolved
@ldmonster ldmonster requested a review from titpetric October 8, 2024 17:18
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