History

Support Proxy protocol (#12527)

This PR adds functionality to allow Gitea to sit behind an HAProxy and HAProxy protocolled connections directly. Fix #7508

zeripath committed 4 years ago

Commit 943753f1 parent 0b4c16615 files · +786 −73Browse files

Showing the changes to cmd/web_https.go (1 of 15 files). Show all

Unified · Split

cmd/web_https.go+5−5
@@ -129,14 +129,14 @@ var ( · 128 unmodified lines
129 defaultCiphersChaChaFirst = append(defaultCiphersChaCha, defaultCiphersAES...)129 defaultCiphersChaChaFirst = append(defaultCiphersChaCha, defaultCiphersAES...)
130)130)
131 131
132// runHTTPs listens on the provided network address and then calls132// runHTTPS listens on the provided network address and then calls
133// Serve to handle requests on incoming TLS connections.133// Serve to handle requests on incoming TLS connections.
134//134//
135// Filenames containing a certificate and matching private key for the server must135// Filenames containing a certificate and matching private key for the server must
136// be provided. If the certificate is signed by a certificate authority, the136// be provided. If the certificate is signed by a certificate authority, the
137// certFile should be the concatenation of the server's certificate followed by the137// certFile should be the concatenation of the server's certificate followed by the
138// CA's certificate.138// CA's certificate.
139func runHTTPS(network, listenAddr, name, certFile, keyFile string, m http.Handler) error {139func runHTTPS(network, listenAddr, name, certFile, keyFile string, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error {
140 tlsConfig := &tls.Config{}140 tlsConfig := &tls.Config{}
141 if tlsConfig.NextProtos == nil {141 if tlsConfig.NextProtos == nil {
142 tlsConfig.NextProtos = []string{"h2", "http/1.1"}142 tlsConfig.NextProtos = []string{"h2", "http/1.1"}
@@ -184,9 +184,9 @@ func runHTTPS(network, listenAddr, name, certFile, keyFile string, m http.Handle · 41 unmodified lines
184 return err184 return err
185 }185 }
186 186
187 return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m)187 return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging)
188}188}
189 189
190func runHTTPSWithTLSConfig(network, listenAddr, name string, tlsConfig *tls.Config, m http.Handler) error {190func runHTTPSWithTLSConfig(network, listenAddr, name string, tlsConfig *tls.Config, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error {
191 return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m)191 return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging)
192}192}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t