Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
a448b5e1
Commit
a448b5e1
authored
Oct 01, 2015
by
David Oppenheimer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14697 from vishh/api-proxy
Avoid rewriting URLs in the proxy, if the application is proxy-aware.
parents
f579f8ed
2788b470
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
transport.go
pkg/util/proxy/transport.go
+4
-1
transport_test.go
pkg/util/proxy/transport_test.go
+8
-0
No files found.
pkg/util/proxy/transport.go
View file @
a448b5e1
...
...
@@ -136,8 +136,11 @@ func (t *Transport) rewriteURL(targetURL string, sourceURL *url.URL) string {
url
.
Scheme
=
t
.
Scheme
url
.
Host
=
t
.
Host
origPath
:=
url
.
Path
// Do not rewrite URL if the sourceURL already contains the necessary prefix.
if
strings
.
HasPrefix
(
url
.
Path
,
t
.
PathPrepend
)
{
return
url
.
String
()
}
url
.
Path
=
path
.
Join
(
t
.
PathPrepend
,
url
.
Path
)
if
strings
.
HasSuffix
(
origPath
,
"/"
)
{
// Add back the trailing slash, which was stripped by path.Join().
url
.
Path
+=
"/"
...
...
pkg/util/proxy/transport_test.go
View file @
a448b5e1
...
...
@@ -150,6 +150,14 @@ func TestProxyTransport(t *testing.T) {
redirectWant
:
"http://example.com/redirected/target/"
,
forwardedURI
:
"/proxy/minion/minion1:10250/redirect"
,
},
"source contains the redirect already"
:
{
input
:
`<pre><a href="kubelet.log">kubelet.log</a><a href="http://foo.com/proxy/minion/minion1:10250/google.log">google.log</a></pre>`
,
sourceURL
:
"http://foo.com/logs/log.log"
,
transport
:
testTransport
,
output
:
`<pre><a href="kubelet.log">kubelet.log</a><a href="http://foo.com/proxy/minion/minion1:10250/google.log">google.log</a></pre>`
,
contentType
:
"text/html"
,
forwardedURI
:
"/proxy/minion/minion1:10250/logs/log.log"
,
},
}
testItem
:=
func
(
name
string
,
item
*
Item
)
{
...
...
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