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
Łukasz Nowak
caddy
Commits
c8307409
Commit
c8307409
authored
7 years ago
by
Sergey Frolov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add global FallbackHosts for vhost matching
parent
ea245b5a
master
nxd-v0.11.0
nxd-v0.11.0-plugins
v0.11.0
v0.10.14
v0.10.13
v0.10.12
v0.10.11
v0.10.10
v0.10.9
v0.10.8
v0.10.7
v0.10.6
v0.10.5
nxd-v0.11.0-3-g12438f6cff8c15f307631151eb064cec579b7605
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
caddyhttp/httpserver/vhosttrie.go
caddyhttp/httpserver/vhosttrie.go
+12
-6
No files found.
caddyhttp/httpserver/vhosttrie.go
View file @
c8307409
...
@@ -45,6 +45,12 @@ func (t *vhostTrie) insertPath(remainingPath, originalPath string, site *SiteCon
...
@@ -45,6 +45,12 @@ func (t *vhostTrie) insertPath(remainingPath, originalPath string, site *SiteCon
t
.
edges
[
ch
]
.
insertPath
(
remainingPath
[
1
:
],
originalPath
,
site
)
t
.
edges
[
ch
]
.
insertPath
(
remainingPath
[
1
:
],
originalPath
,
site
)
}
}
// When matching a site, the given host will be tried first.
// Then, FallbackHosts will be tried in order.
// Default FallbackHosts are following wildcards,
// which could be modified by plugins and directives.
var
FallbackHosts
=
[]
string
{
"0.0.0.0"
,
""
}
// Match returns the virtual host (site) in v with
// Match returns the virtual host (site) in v with
// the closest match to key. If there was a match,
// the closest match to key. If there was a match,
// it returns the SiteConfig and the path portion of
// it returns the SiteConfig and the path portion of
...
@@ -57,13 +63,13 @@ func (t *vhostTrie) insertPath(remainingPath, originalPath string, site *SiteCon
...
@@ -57,13 +63,13 @@ func (t *vhostTrie) insertPath(remainingPath, originalPath string, site *SiteCon
// A typical key will be in the form "host" or "host/path".
// A typical key will be in the form "host" or "host/path".
func
(
t
*
vhostTrie
)
Match
(
key
string
)
(
*
SiteConfig
,
string
)
{
func
(
t
*
vhostTrie
)
Match
(
key
string
)
(
*
SiteConfig
,
string
)
{
host
,
path
:=
t
.
splitHostPath
(
key
)
host
,
path
:=
t
.
splitHostPath
(
key
)
// try the given host, then, if no match, try
wildcard
hosts
// try the given host, then, if no match, try
fallback
hosts
branch
:=
t
.
matchHost
(
host
)
branch
:=
t
.
matchHost
(
host
)
if
branch
==
nil
{
for
_
,
h
:=
range
FallbackHosts
{
branch
=
t
.
matchHost
(
"0.0.0.0"
)
if
branch
!=
nil
{
break
}
}
if
branch
==
nil
{
branch
=
t
.
matchHost
(
h
)
branch
=
t
.
matchHost
(
""
)
}
}
if
branch
==
nil
{
if
branch
==
nil
{
return
nil
,
""
return
nil
,
""
...
...
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