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
bae4ac97
Commit
bae4ac97
authored
Jan 23, 2016
by
Filippo Valsorda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: add a insecure_skip_verify option - closes #320
parent
6e340cb1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
middleware/proxy/reverseproxy.go
middleware/proxy/reverseproxy.go
+11
-0
middleware/proxy/upstream.go
middleware/proxy/upstream.go
+10
-4
No files found.
middleware/proxy/reverseproxy.go
View file @
bae4ac97
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
package
proxy
package
proxy
import
(
import
(
"crypto/tls"
"io"
"io"
"net"
"net"
"net/http"
"net/http"
...
@@ -103,6 +104,16 @@ var hopHeaders = []string{
...
@@ -103,6 +104,16 @@ var hopHeaders = []string{
"Upgrade"
,
"Upgrade"
,
}
}
var
InsecureTransport
http
.
RoundTripper
=
&
http
.
Transport
{
Proxy
:
http
.
ProxyFromEnvironment
,
Dial
:
(
&
net
.
Dialer
{
Timeout
:
30
*
time
.
Second
,
KeepAlive
:
30
*
time
.
Second
,
})
.
Dial
,
TLSHandshakeTimeout
:
10
*
time
.
Second
,
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
}
func
(
p
*
ReverseProxy
)
ServeHTTP
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
,
extraHeaders
http
.
Header
)
error
{
func
(
p
*
ReverseProxy
)
ServeHTTP
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
,
extraHeaders
http
.
Header
)
error
{
transport
:=
p
.
Transport
transport
:=
p
.
Transport
if
transport
==
nil
{
if
transport
==
nil
{
...
...
middleware/proxy/upstream.go
View file @
bae4ac97
...
@@ -23,6 +23,7 @@ type staticUpstream struct {
...
@@ -23,6 +23,7 @@ type staticUpstream struct {
proxyHeaders
http
.
Header
proxyHeaders
http
.
Header
Hosts
HostPool
Hosts
HostPool
Policy
Policy
Policy
Policy
insecureSkipVerify
bool
FailTimeout
time
.
Duration
FailTimeout
time
.
Duration
MaxFails
int32
MaxFails
int32
...
@@ -90,6 +91,9 @@ func NewStaticUpstreams(c parse.Dispenser) ([]Upstream, error) {
...
@@ -90,6 +91,9 @@ func NewStaticUpstreams(c parse.Dispenser) ([]Upstream, error) {
}
}
if
baseURL
,
err
:=
url
.
Parse
(
uh
.
Name
);
err
==
nil
{
if
baseURL
,
err
:=
url
.
Parse
(
uh
.
Name
);
err
==
nil
{
uh
.
ReverseProxy
=
NewSingleHostReverseProxy
(
baseURL
,
uh
.
WithoutPathPrefix
)
uh
.
ReverseProxy
=
NewSingleHostReverseProxy
(
baseURL
,
uh
.
WithoutPathPrefix
)
if
upstream
.
insecureSkipVerify
{
uh
.
ReverseProxy
.
Transport
=
InsecureTransport
}
}
else
{
}
else
{
return
upstreams
,
err
return
upstreams
,
err
}
}
...
@@ -175,6 +179,8 @@ func parseBlock(c *parse.Dispenser, u *staticUpstream) error {
...
@@ -175,6 +179,8 @@ func parseBlock(c *parse.Dispenser, u *staticUpstream) error {
return
c
.
ArgErr
()
return
c
.
ArgErr
()
}
}
u
.
IgnoredSubPaths
=
ignoredPaths
u
.
IgnoredSubPaths
=
ignoredPaths
case
"insecure_skip_verify"
:
u
.
insecureSkipVerify
=
true
default
:
default
:
return
c
.
Errf
(
"unknown property '%s'"
,
c
.
Val
())
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