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
5b5e3652
Commit
5b5e3652
authored
Aug 05, 2016
by
Nimi Wariboko Jr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instead of treating 0 is a default value, use http.DefaultMaxIdleConnsPerHost
parent
db4cd8ee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
6 deletions
+13
-6
caddyhttp/proxy/proxy.go
caddyhttp/proxy/proxy.go
+1
-1
caddyhttp/proxy/proxy_test.go
caddyhttp/proxy/proxy_test.go
+3
-3
caddyhttp/proxy/reverseproxy.go
caddyhttp/proxy/reverseproxy.go
+5
-2
caddyhttp/proxy/upstream.go
caddyhttp/proxy/upstream.go
+4
-0
No files found.
caddyhttp/proxy/proxy.go
View file @
5b5e3652
...
...
@@ -108,7 +108,7 @@ func (p Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
if
nameURL
,
err
:=
url
.
Parse
(
host
.
Name
);
err
==
nil
{
outreq
.
Host
=
nameURL
.
Host
if
proxy
==
nil
{
proxy
=
NewSingleHostReverseProxy
(
nameURL
,
host
.
WithoutPathPrefix
,
0
)
proxy
=
NewSingleHostReverseProxy
(
nameURL
,
host
.
WithoutPathPrefix
,
http
.
DefaultMaxIdleConnsPerHost
)
}
// use upstream credentials by default
...
...
caddyhttp/proxy/proxy_test.go
View file @
5b5e3652
...
...
@@ -716,7 +716,7 @@ func newFakeUpstream(name string, insecure bool) *fakeUpstream {
from
:
"/"
,
host
:
&
UpstreamHost
{
Name
:
name
,
ReverseProxy
:
NewSingleHostReverseProxy
(
uri
,
""
,
0
),
ReverseProxy
:
NewSingleHostReverseProxy
(
uri
,
""
,
http
.
DefaultMaxIdleConnsPerHost
),
},
}
if
insecure
{
...
...
@@ -744,7 +744,7 @@ func (u *fakeUpstream) Select() *UpstreamHost {
}
u
.
host
=
&
UpstreamHost
{
Name
:
u
.
name
,
ReverseProxy
:
NewSingleHostReverseProxy
(
uri
,
u
.
without
,
0
),
ReverseProxy
:
NewSingleHostReverseProxy
(
uri
,
u
.
without
,
http
.
DefaultMaxIdleConnsPerHost
),
}
}
return
u
.
host
...
...
@@ -785,7 +785,7 @@ func (u *fakeWsUpstream) Select() *UpstreamHost {
uri
,
_
:=
url
.
Parse
(
u
.
name
)
return
&
UpstreamHost
{
Name
:
u
.
name
,
ReverseProxy
:
NewSingleHostReverseProxy
(
uri
,
u
.
without
,
0
),
ReverseProxy
:
NewSingleHostReverseProxy
(
uri
,
u
.
without
,
http
.
DefaultMaxIdleConnsPerHost
),
UpstreamHeaders
:
http
.
Header
{
"Connection"
:
{
"{>Connection}"
},
"Upgrade"
:
{
"{>Upgrade}"
}},
...
...
caddyhttp/proxy/reverseproxy.go
View file @
5b5e3652
...
...
@@ -122,7 +122,10 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int) *
rp
.
Transport
=
&
http
.
Transport
{
Dial
:
socketDial
(
target
.
String
()),
}
}
else
if
keepalive
!=
0
{
}
else
if
keepalive
!=
http
.
DefaultMaxIdleConnsPerHost
{
// if keepalive is equal to the default,
// just use default transport, to avoid creating
// a brand new transport
rp
.
Transport
=
&
http
.
Transport
{
Proxy
:
http
.
ProxyFromEnvironment
,
Dial
:
(
&
net
.
Dialer
{
...
...
@@ -132,7 +135,7 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int) *
TLSHandshakeTimeout
:
10
*
time
.
Second
,
ExpectContinueTimeout
:
1
*
time
.
Second
,
}
if
keepalive
<
0
{
if
keepalive
==
0
{
rp
.
Transport
.
(
*
http
.
Transport
)
.
DisableKeepAlives
=
true
}
else
{
rp
.
Transport
.
(
*
http
.
Transport
)
.
MaxIdleConnsPerHost
=
keepalive
...
...
caddyhttp/proxy/upstream.go
View file @
5b5e3652
...
...
@@ -55,6 +55,7 @@ func NewStaticUpstreams(c caddyfile.Dispenser) ([]Upstream, error) {
FailTimeout
:
10
*
time
.
Second
,
MaxFails
:
1
,
MaxConns
:
0
,
KeepAlive
:
http
.
DefaultMaxIdleConnsPerHost
,
}
if
!
c
.
Args
(
&
upstream
.
from
)
{
...
...
@@ -321,6 +322,9 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error {
if
err
!=
nil
{
return
err
}
if
n
<
0
{
return
c
.
ArgErr
()
}
u
.
KeepAlive
=
n
default
:
return
c
.
Errf
(
"unknown property '%s'"
,
c
.
Val
())
...
...
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