Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
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
DEMO
spring-boot
Commits
d30dd1fa
Commit
d30dd1fa
authored
Jun 22, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
7d845391
01ba0f75
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+14
-0
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+3
-0
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
d30dd1fa
...
@@ -306,6 +306,11 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -306,6 +306,11 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
*/
*/
private
String
protocolHeader
;
private
String
protocolHeader
;
/**
* Value of the protocol header that indicates that the incoming request uses SSL.
*/
private
String
protocolHeaderHttpsValue
=
"https"
;
/**
/**
* Name of the HTTP header used to override the original port value.
* Name of the HTTP header used to override the original port value.
*/
*/
...
@@ -435,6 +440,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -435,6 +440,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
this
.
protocolHeader
=
protocolHeader
;
this
.
protocolHeader
=
protocolHeader
;
}
}
public
String
getProtocolHeaderHttpsValue
()
{
return
this
.
protocolHeaderHttpsValue
;
}
public
void
setProtocolHeaderHttpsValue
(
String
protocolHeaderHttpsValue
)
{
this
.
protocolHeaderHttpsValue
=
protocolHeaderHttpsValue
;
}
public
String
getPortHeader
()
{
public
String
getPortHeader
()
{
return
this
.
portHeader
;
return
this
.
portHeader
;
}
}
...
@@ -502,6 +515,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -502,6 +515,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
valve
.
setProtocolHeader
(
protocolHeader
);
valve
.
setProtocolHeader
(
protocolHeader
);
valve
.
setInternalProxies
(
getInternalProxies
());
valve
.
setInternalProxies
(
getInternalProxies
());
valve
.
setPortHeader
(
getPortHeader
());
valve
.
setPortHeader
(
getPortHeader
());
valve
.
setProtocolHeaderHttpsValue
(
getProtocolHeaderHttpsValue
());
factory
.
addContextValves
(
valve
);
factory
.
addContextValves
(
valve
);
}
}
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
View file @
d30dd1fa
...
@@ -192,6 +192,7 @@ public class ServerPropertiesTests {
...
@@ -192,6 +192,7 @@ public class ServerPropertiesTests {
assertThat
(
valve
,
instanceOf
(
RemoteIpValve
.
class
));
assertThat
(
valve
,
instanceOf
(
RemoteIpValve
.
class
));
RemoteIpValve
remoteIpValve
=
(
RemoteIpValve
)
valve
;
RemoteIpValve
remoteIpValve
=
(
RemoteIpValve
)
valve
;
assertEquals
(
"x-forwarded-proto"
,
remoteIpValve
.
getProtocolHeader
());
assertEquals
(
"x-forwarded-proto"
,
remoteIpValve
.
getProtocolHeader
());
assertEquals
(
"https"
,
remoteIpValve
.
getProtocolHeaderHttpsValue
());
assertEquals
(
"x-forwarded-for"
,
remoteIpValve
.
getRemoteIpHeader
());
assertEquals
(
"x-forwarded-for"
,
remoteIpValve
.
getRemoteIpHeader
());
String
expectedInternalProxies
=
"10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|"
// 10/8
String
expectedInternalProxies
=
"10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|"
// 10/8
...
@@ -212,6 +213,7 @@ public class ServerPropertiesTests {
...
@@ -212,6 +213,7 @@ public class ServerPropertiesTests {
map
.
put
(
"server.tomcat.protocol_header"
,
"x-my-protocol-header"
);
map
.
put
(
"server.tomcat.protocol_header"
,
"x-my-protocol-header"
);
map
.
put
(
"server.tomcat.internal_proxies"
,
"192.168.0.1"
);
map
.
put
(
"server.tomcat.internal_proxies"
,
"192.168.0.1"
);
map
.
put
(
"server.tomcat.port-header"
,
"x-my-forward-port"
);
map
.
put
(
"server.tomcat.port-header"
,
"x-my-forward-port"
);
map
.
put
(
"server.tomcat.protocol-header-https-value"
,
"On"
);
bindProperties
(
map
);
bindProperties
(
map
);
TomcatEmbeddedServletContainerFactory
container
=
new
TomcatEmbeddedServletContainerFactory
();
TomcatEmbeddedServletContainerFactory
container
=
new
TomcatEmbeddedServletContainerFactory
();
...
@@ -222,6 +224,7 @@ public class ServerPropertiesTests {
...
@@ -222,6 +224,7 @@ public class ServerPropertiesTests {
assertThat
(
valve
,
instanceOf
(
RemoteIpValve
.
class
));
assertThat
(
valve
,
instanceOf
(
RemoteIpValve
.
class
));
RemoteIpValve
remoteIpValve
=
(
RemoteIpValve
)
valve
;
RemoteIpValve
remoteIpValve
=
(
RemoteIpValve
)
valve
;
assertEquals
(
"x-my-protocol-header"
,
remoteIpValve
.
getProtocolHeader
());
assertEquals
(
"x-my-protocol-header"
,
remoteIpValve
.
getProtocolHeader
());
assertEquals
(
"On"
,
remoteIpValve
.
getProtocolHeaderHttpsValue
());
assertEquals
(
"x-my-remote-ip-header"
,
remoteIpValve
.
getRemoteIpHeader
());
assertEquals
(
"x-my-remote-ip-header"
,
remoteIpValve
.
getRemoteIpHeader
());
assertEquals
(
"x-my-forward-port"
,
remoteIpValve
.
getPortHeader
());
assertEquals
(
"x-my-forward-port"
,
remoteIpValve
.
getPortHeader
());
assertEquals
(
"192.168.0.1"
,
remoteIpValve
.
getInternalProxies
());
assertEquals
(
"192.168.0.1"
,
remoteIpValve
.
getInternalProxies
());
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
d30dd1fa
...
@@ -99,6 +99,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -99,6 +99,7 @@ content into your application; rather pick only the properties that you need.
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses
server.tomcat.protocol-header=x-forwarded-proto # front end proxy forward header
server.tomcat.protocol-header=x-forwarded-proto # front end proxy forward header
server.tomcat.protocol-header-https-value=https # value of the protocol header that indicates that the incoming request uses SSL
server.tomcat.port-header= # front end proxy port header
server.tomcat.port-header= # front end proxy port header
server.tomcat.remote-ip-header=x-forwarded-for
server.tomcat.remote-ip-header=x-forwarded-for
server.tomcat.basedir=/tmp # base dir (usually not needed, defaults to tmp)
server.tomcat.basedir=/tmp # base dir (usually not needed, defaults to tmp)
...
...
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