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
4baca884
Commit
4baca884
authored
Oct 11, 2016
by
Tw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: preserve path trailing slash if it was there
fix issue #1177 Signed-off-by:
Tw
<
tw19881113@gmail.com
>
parent
9ced4b17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
caddyhttp/proxy/proxy_test.go
caddyhttp/proxy/proxy_test.go
+5
-0
caddyhttp/proxy/reverseproxy.go
caddyhttp/proxy/reverseproxy.go
+6
-0
No files found.
caddyhttp/proxy/proxy_test.go
View file @
4baca884
...
...
@@ -791,6 +791,11 @@ func TestProxyDirectorURL(t *testing.T) {
expectURL
:
`https://localhost:2021/t?foo%3dbar&t%3dw`
,
without
:
"/test"
,
},
{
requestURL
:
`http://localhost:2020/test/`
,
targetURL
:
`https://localhost:2021/t/`
,
expectURL
:
`https://localhost:2021/t/test/`
,
},
}
{
targetURL
,
err
:=
url
.
Parse
(
c
.
targetURL
)
if
err
!=
nil
{
...
...
caddyhttp/proxy/reverseproxy.go
View file @
4baca884
...
...
@@ -96,7 +96,13 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int) *
}
}
hadTrailingSlash
:=
strings
.
HasSuffix
(
req
.
URL
.
Path
,
"/"
)
req
.
URL
.
Path
=
path
.
Join
(
target
.
Path
,
req
.
URL
.
Path
)
// path.Join will strip off the last /, so put it back if it was there.
if
hadTrailingSlash
&&
!
strings
.
HasSuffix
(
req
.
URL
.
Path
,
"/"
)
{
req
.
URL
.
Path
=
req
.
URL
.
Path
+
"/"
}
// Trims the path of the socket from the URL path.
// This is done because req.URL passed to your proxied service
// will have the full path of the socket file prefixed to 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