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

backport: kube: always enable proxy protocol support #5382

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/kube/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/gravitational/teleport/lib/auth"
"github.com/gravitational/teleport/lib/defaults"
"github.com/gravitational/teleport/lib/limiter"
"github.com/gravitational/teleport/lib/multiplexer"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/srv"
"github.com/gravitational/teleport/lib/utils"
Expand Down Expand Up @@ -153,15 +154,30 @@ func NewTLSServer(cfg TLSServerConfig) (*TLSServer, error) {

// Serve takes TCP listener, upgrades to TLS using config and starts serving
func (t *TLSServer) Serve(listener net.Listener) error {
// Wrap listener with a multiplexer to get Proxy Protocol support.
mux, err := multiplexer.New(multiplexer.Config{
Context: t.Context,
Listener: listener,
Clock: t.Clock,
EnableProxyProtocol: true,
DisableSSH: true,
ID: t.Component,
})
if err != nil {
return trace.Wrap(err)
}
go mux.Serve()
defer mux.Close()

t.mu.Lock()
t.listener = listener
t.listener = mux.TLS()
t.mu.Unlock()

if t.heartbeat != nil {
go t.heartbeat.Run()
}

return t.Server.Serve(tls.NewListener(listener, t.TLS))
return t.Server.Serve(tls.NewListener(mux.TLS(), t.TLS))
}

// Close closes the server and cleans up all resources.
Expand Down