55package proxy
66
77import (
8+ "crypto/tls"
89 "fmt"
910 "net"
1011 "net/http"
@@ -37,6 +38,9 @@ func (ppc *proxyPassConfig) appendResponseHandler(handler responseHandler) {
3738// proxyPassOpt allows to compose ProxyHandler options.
3839type proxyPassOpt func (h * proxyPassConfig )
3940
41+ // createHttpTransportOpt allows to compose create http Transport options.
42+ type createHttpTransportOpt func (h * http.Transport )
43+
4044// errorHandler is a function that handles an error that occurred during proxying of a HTTP request.
4145type errorHandler func (http.ResponseWriter , * http.Request , error )
4246
@@ -218,10 +222,16 @@ func withErrorHandler(h errorHandler) proxyPassOpt {
218222 }
219223}
220224
221- func createDefaultTransport (config * TransportConfig ) http.RoundTripper {
222- // TODO equivalent of client_max_body_size 2048m; necessary ???
223- // this is based on http.DefaultTransport, with some values exposed to config
224- return instrumentClientMetrics (& http.Transport {
225+ func withSkipTLSVerify () createHttpTransportOpt {
226+ return func (tr * http.Transport ) {
227+ tr .TLSClientConfig = & tls.Config {
228+ InsecureSkipVerify : true ,
229+ }
230+ }
231+ }
232+
233+ func createDefaultTransport (config * TransportConfig , opts ... createHttpTransportOpt ) http.RoundTripper {
234+ transport := & http.Transport {
225235 Proxy : http .ProxyFromEnvironment ,
226236 DialContext : (& net.Dialer {
227237 Timeout : time .Duration (config .ConnectTimeout ), // default: 30s
@@ -234,7 +244,13 @@ func createDefaultTransport(config *TransportConfig) http.RoundTripper {
234244 IdleConnTimeout : time .Duration (config .IdleConnTimeout ), // default: 90s
235245 TLSHandshakeTimeout : 10 * time .Second ,
236246 ExpectContinueTimeout : 1 * time .Second ,
237- })
247+ }
248+ for _ , o := range opts {
249+ o (transport )
250+ }
251+ // TODO equivalent of client_max_body_size 2048m; necessary ???
252+ // this is based on http.DefaultTransport, with some values exposed to config
253+ return instrumentClientMetrics (transport )
238254}
239255
240256// tell the browser to cache for 1 year and don't ask the server during this period.
0 commit comments