Skip to content

Commit

Permalink
get TLS certificate before start each proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidapaulopt committed Oct 21, 2024
1 parent 6df2023 commit f310279
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/proxymanager/proxymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package proxymanager

import (
"context"
"crypto/tls"
"errors"
"fmt"
"net"
Expand Down Expand Up @@ -139,13 +140,25 @@ func (pm *ProxyManager) SetupProxy(ctx context.Context, containerID string) {
}
defer ln.Close()

lc, err := server.LocalClient()
if err != nil {
pm.Log.Error().Err(err).Str("containerID", containerID).Msg("Error setting LocalClient")
return
}

ln = tls.NewListener(ln, &tls.Config{
GetCertificate: lc.GetCertificate,
})

// AddProxy to the list
pm.AddProxy(&Proxy{
container: container,
TsServer: server,
URL: proxyURL,
reverseProxy: reverseProxy,
})

// start server
err = http.Serve(ln, pm.reverseProxyFunc(reverseProxy))
defer log.Printf("Terminating server %s", proxyURL.Hostname())

Expand Down

0 comments on commit f310279

Please sign in to comment.