allow to configure ALPN protocols

Fixes #1406

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-10-28 12:35:26 +02:00
parent 691e44c1dc
commit 4a15775f65
16 changed files with 129 additions and 62 deletions

View File

@@ -499,11 +499,13 @@ type Binding struct {
// Note that TLS 1.3 ciphersuites are not configurable.
// The supported ciphersuites names are defined here:
//
// https://github.com/golang/go/blob/master/src/crypto/tls/cipher_suites.go#L52
// https://github.com/golang/go/blob/master/src/crypto/tls/cipher_suites.go#L53
//
// any invalid name will be silently ignored.
// The order matters, the ciphers listed first will be the preferred ones.
TLSCipherSuites []string `json:"tls_cipher_suites" mapstructure:"tls_cipher_suites"`
// HTTP protocols in preference order. Supported values: http/1.1, h2
Protocols []string `json:"protocols" mapstructure:"protocols"`
// List of IP addresses and IP ranges allowed to set client IP proxy headers and
// X-Forwarded-Proto header.
ProxyAllowed []string `json:"proxy_allowed" mapstructure:"proxy_allowed"`

View File

@@ -110,7 +110,7 @@ func (s *httpdServer) listenAndServe() error {
config := &tls.Config{
GetCertificate: certMgr.GetCertificateFunc(certID),
MinVersion: util.GetTLSVersion(s.binding.MinTLSVersion),
NextProtos: []string{"http/1.1", "h2"},
NextProtos: util.GetALPNProtocols(s.binding.Protocols),
CipherSuites: util.GetTLSCiphersFromNames(s.binding.TLSCipherSuites),
}
httpServer.TLSConfig = config