Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
cb90cd99
Commit
cb90cd99
authored
Mar 24, 2017
by
gonzalad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add X-Forwarded-Port header in Zuul
Add X-Forwarded-Port header in Zuul PreDecorationFilter even with X-Forwarded-Host header being absent.
parent
d402587a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
PreDecorationFilter.java
...k/cloud/netflix/zuul/filters/pre/PreDecorationFilter.java
+12
-12
PreDecorationFilterTests.java
...ud/netflix/zuul/filters/pre/PreDecorationFilterTests.java
+1
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/PreDecorationFilter.java
View file @
cb90cd99
...
...
@@ -198,21 +198,21 @@ public class PreDecorationFilter extends ZuulFilter {
String
proto
=
request
.
getScheme
();
if
(
hasHeader
(
request
,
X_FORWARDED_HOST_HEADER
))
{
host
=
request
.
getHeader
(
X_FORWARDED_HOST_HEADER
)
+
","
+
host
;
if
(!
hasHeader
(
request
,
X_FORWARDED_PORT_HEADER
))
{
if
(
hasHeader
(
request
,
X_FORWARDED_PROTO_HEADER
))
{
StringBuilder
builder
=
new
StringBuilder
();
for
(
String
previous
:
StringUtils
.
commaDelimitedListToStringArray
(
request
.
getHeader
(
X_FORWARDED_PROTO_HEADER
)))
{
if
(
builder
.
length
()>
0
)
{
builder
.
append
(
","
);
}
builder
.
append
(
HTTPS_SCHEME
.
equals
(
previous
)
?
HTTPS_PORT
:
HTTP_PORT
);
}
if
(!
hasHeader
(
request
,
X_FORWARDED_PORT_HEADER
))
{
if
(
hasHeader
(
request
,
X_FORWARDED_PROTO_HEADER
))
{
StringBuilder
builder
=
new
StringBuilder
();
for
(
String
previous
:
StringUtils
.
commaDelimitedListToStringArray
(
request
.
getHeader
(
X_FORWARDED_PROTO_HEADER
)))
{
if
(
builder
.
length
()>
0
)
{
builder
.
append
(
","
);
}
builder
.
append
(
","
).
append
(
port
);
port
=
builder
.
toString
();
builder
.
append
(
HTTPS_SCHEME
.
equals
(
previous
)
?
HTTPS_PORT
:
HTTP_PORT
);
}
}
else
{
port
=
request
.
getHeader
(
X_FORWARDED_PORT_HEADER
)
+
","
+
port
;
builder
.
append
(
","
).
append
(
port
);
port
=
builder
.
toString
()
;
}
}
else
{
port
=
request
.
getHeader
(
X_FORWARDED_PORT_HEADER
)
+
","
+
port
;
}
if
(
hasHeader
(
request
,
X_FORWARDED_PROTO_HEADER
))
{
proto
=
request
.
getHeader
(
X_FORWARDED_PROTO_HEADER
)
+
","
+
proto
;
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/pre/PreDecorationFilterTests.java
View file @
cb90cd99
...
...
@@ -152,7 +152,7 @@ public class PreDecorationFilterTests {
this
.
filter
.
run
();
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
assertEquals
(
"localhost:8080"
,
ctx
.
getZuulRequestHeaders
().
get
(
"x-forwarded-host"
));
assertEquals
(
"8080"
,
ctx
.
getZuulRequestHeaders
().
get
(
"x-forwarded-port"
));
assertEquals
(
"
443,
8080"
,
ctx
.
getZuulRequestHeaders
().
get
(
"x-forwarded-port"
));
assertEquals
(
"https,http"
,
ctx
.
getZuulRequestHeaders
().
get
(
"x-forwarded-proto"
));
}
...
...
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