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
9f793dad
Commit
9f793dad
authored
9 years ago
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proxy destination may include scheme
parent
f2f5d498
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
middleware/proxy/proxy.go
middleware/proxy/proxy.go
+15
-5
No files found.
middleware/proxy/proxy.go
View file @
9f793dad
...
...
@@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httputil"
"net/url"
"strings"
"github.com/mholt/caddy/middleware"
)
...
...
@@ -29,14 +30,23 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
for
_
,
rule
:=
range
rules
{
if
middleware
.
Path
(
r
.
URL
.
Path
)
.
Matches
(
rule
.
from
)
{
var
base
string
if
strings
.
HasPrefix
(
rule
.
to
,
"http"
)
{
// includes https
// destination includes a scheme! no need to guess
base
=
rule
.
to
}
else
{
// no scheme specified; assume same as request
var
scheme
string
if
r
.
TLS
==
nil
{
scheme
=
"http"
}
else
{
scheme
=
"https"
}
base
=
scheme
+
"://"
+
rule
.
to
}
baseUrl
,
err
:=
url
.
Parse
(
scheme
+
"://"
+
rule
.
to
)
baseUrl
,
err
:=
url
.
Parse
(
base
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
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