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
129129 defaultCiphersChaChaFirst = append(defaultCiphersChaCha, defaultCiphersAES...)
130130 )
131131
132−// runHTTPs listens on the provided network address and then calls
132+// runHTTPS listens on the provided network address and then calls
133133 // Serve to handle requests on incoming TLS connections.
134134 //
135135 // Filenames containing a certificate and matching private key for the server must
136136 // be provided. If the certificate is signed by a certificate authority, the
137137 // certFile should be the concatenation of the server's certificate followed by the
138138 // CA's certificate.
139−func runHTTPS(network, listenAddr, name, certFile, keyFile string, m http.Handler) error {
139+func runHTTPS(network, listenAddr, name, certFile, keyFile string, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error {
140140 tlsConfig := &tls.Config{}
141141 if tlsConfig.NextProtos == nil {
142142 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
184184 return err
185185 }
186186
187− return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m)
187+ return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging)
188188 }
189189
190−func runHTTPSWithTLSConfig(network, listenAddr, name string, tlsConfig *tls.Config, m http.Handler) error {
191− return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m)
190+func runHTTPSWithTLSConfig(network, listenAddr, name string, tlsConfig *tls.Config, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error {
191+ return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging)
192192 }

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