mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-19 11:36:57 +00:00
feat: add proxy protocol support (#394)
This can be useful when the pages-server is running behing a proxy, to keep track of the originating ip. Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/394 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Julien Malka <julien@malka.sh> Co-committed-by: Julien Malka <julien@malka.sh>
This commit is contained in:
parent
168bc9047b
commit
bb7cfbb37c
6 changed files with 29 additions and 3 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pires/go-proxyproto"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -95,6 +96,9 @@ func Serve(ctx *cli.Context) error {
|
|||
return fmt.Errorf("couldn't create listener: %v", err)
|
||||
}
|
||||
|
||||
if cfg.Server.UseProxyProtocol {
|
||||
listener = &proxyproto.Listener{Listener: listener}
|
||||
}
|
||||
// Setup listener for SSL connections
|
||||
listener = tls.NewListener(listener, certificates.TLSConfig(
|
||||
cfg.Server.MainDomain,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue