Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
fe664c00
Commit
fe664c00
authored
Apr 28, 2018
by
Wèi Cōngruì
Committed by
Matt Holt
Apr 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: initialize ReverseProxy.Transport earlier and fix TCP connection leak (#2134)
parent
2922d09b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
17 deletions
+10
-17
caddyhttp/proxy/reverseproxy.go
caddyhttp/proxy/reverseproxy.go
+10
-17
No files found.
caddyhttp/proxy/reverseproxy.go
View file @
fe664c00
...
...
@@ -85,7 +85,6 @@ type ReverseProxy struct {
Director
func
(
*
http
.
Request
)
// The transport used to perform proxy requests.
// If nil, http.DefaultTransport is used.
Transport
http
.
RoundTripper
// FlushInterval specifies the flush interval
...
...
@@ -274,6 +273,15 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int, t
http2
.
ConfigureTransport
(
transport
)
}
rp
.
Transport
=
transport
}
else
{
transport
:=
&
http
.
Transport
{
Proxy
:
http
.
ProxyFromEnvironment
,
Dial
:
rp
.
dialer
.
Dial
,
}
if
httpserver
.
HTTP2
{
http2
.
ConfigureTransport
(
transport
)
}
rp
.
Transport
=
transport
}
return
rp
}
...
...
@@ -282,18 +290,7 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int, t
// when it is OK for upstream to be using a bad certificate,
// since this transport skips verification.
func
(
rp
*
ReverseProxy
)
UseInsecureTransport
()
{
if
rp
.
Transport
==
nil
{
transport
:=
&
http
.
Transport
{
Proxy
:
http
.
ProxyFromEnvironment
,
Dial
:
rp
.
dialer
.
Dial
,
TLSHandshakeTimeout
:
defaultCryptoHandshakeTimeout
,
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
}
if
httpserver
.
HTTP2
{
http2
.
ConfigureTransport
(
transport
)
}
rp
.
Transport
=
transport
}
else
if
transport
,
ok
:=
rp
.
Transport
.
(
*
http
.
Transport
);
ok
{
if
transport
,
ok
:=
rp
.
Transport
.
(
*
http
.
Transport
);
ok
{
if
transport
.
TLSClientConfig
==
nil
{
transport
.
TLSClientConfig
=
&
tls
.
Config
{}
}
...
...
@@ -315,10 +312,6 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
transport
:=
rp
.
Transport
if
requestIsWebsocket
(
outreq
)
{
transport
=
newConnHijackerTransport
(
transport
)
}
else
if
transport
==
nil
{
transport
=
&
http
.
Transport
{
Dial
:
rp
.
dialer
.
Dial
,
}
}
rp
.
Director
(
outreq
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment