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
b5ec4622
Commit
b5ec4622
authored
Aug 09, 2017
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal: Allow use for only X-Accel-Redir (closes #1020)
(allow no arguments of paths to protect)
parent
61798884
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
caddyhttp/internalsrv/internal.go
caddyhttp/internalsrv/internal.go
+0
-2
caddyhttp/internalsrv/setup.go
caddyhttp/internalsrv/setup.go
+5
-3
caddyhttp/internalsrv/setup_test.go
caddyhttp/internalsrv/setup_test.go
+4
-0
No files found.
caddyhttp/internalsrv/internal.go
View file @
b5ec4622
...
...
@@ -32,7 +32,6 @@ func isInternalRedirect(w http.ResponseWriter) bool {
// ServeHTTP implements the httpserver.Handler interface.
func
(
i
Internal
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
int
,
error
)
{
// Internal location requested? -> Not found.
for
_
,
prefix
:=
range
i
.
Paths
{
if
httpserver
.
Path
(
r
.
URL
.
Path
)
.
Matches
(
prefix
)
{
...
...
@@ -50,7 +49,6 @@ func (i Internal) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
// "down the chain"
r
.
URL
.
Path
=
iw
.
Header
()
.
Get
(
redirectHeader
)
iw
.
ClearHeader
()
status
,
err
=
i
.
Next
.
ServeHTTP
(
iw
,
r
)
}
...
...
caddyhttp/internalsrv/setup.go
View file @
b5ec4622
...
...
@@ -30,10 +30,12 @@ func internalParse(c *caddy.Controller) ([]string, error) {
var
paths
[]
string
for
c
.
Next
()
{
if
!
c
.
NextArg
()
{
return
paths
,
c
.
ArgErr
()
if
c
.
NextArg
()
{
paths
=
append
(
paths
,
c
.
Val
())
}
if
c
.
NextArg
()
{
return
nil
,
c
.
ArgErr
()
}
paths
=
append
(
paths
,
c
.
Val
())
}
return
paths
,
nil
...
...
caddyhttp/internalsrv/setup_test.go
View file @
b5ec4622
...
...
@@ -41,10 +41,14 @@ func TestInternalParse(t *testing.T) {
shouldErr
bool
expectedInternalPaths
[]
string
}{
{
`internal`
,
false
,
[]
string
{}},
{
`internal /internal`
,
false
,
[]
string
{
"/internal"
}},
{
`internal /internal1
internal /internal2`
,
false
,
[]
string
{
"/internal1"
,
"/internal2"
}},
{
`internal /internal1 /internal2`
,
true
,
nil
},
}
for
i
,
test
:=
range
tests
{
actualInternalPaths
,
err
:=
internalParse
(
caddy
.
NewTestController
(
"http"
,
test
.
inputInternalPaths
))
...
...
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