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
2e3658fd
Commit
2e3658fd
authored
Sep 28, 2015
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable RemoteIpValve by default
Fixes gh-3782
parent
c8ec2cb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
21 deletions
+16
-21
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+4
-4
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+12
-17
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
2e3658fd
...
@@ -484,9 +484,9 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -484,9 +484,9 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
/**
/**
* Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
* Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
* Configure
d a
s a RemoteIpValve only if remoteIpHeader is also set.
* Configures a RemoteIpValve only if remoteIpHeader is also set.
*/
*/
private
String
protocolHeader
;
private
String
protocolHeader
=
"x-forwarded-proto"
;
/**
/**
* Value of the protocol header that indicates that the incoming request uses SSL.
* Value of the protocol header that indicates that the incoming request uses SSL.
...
@@ -499,8 +499,8 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -499,8 +499,8 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
private
String
portHeader
=
"x-forwarded-port"
;
private
String
portHeader
=
"x-forwarded-port"
;
/**
/**
* Name of the http header from which the remote ip is extracted. Configure
d a
s a
* Name of the http header from which the remote ip is extracted. Configures a
* RemoteIpValve only if
remoteIp
Header is also set.
* RemoteIpValve only if
protocol
Header is also set.
*/
*/
private
String
remoteIpHeader
=
"x-forwarded-for"
;
private
String
remoteIpHeader
=
"x-forwarded-for"
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
View file @
2e3658fd
...
@@ -16,6 +16,17 @@
...
@@ -16,6 +16,17 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
atLeastOnce
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -41,17 +52,6 @@ import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCont
...
@@ -41,17 +52,6 @@ import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCont
import
org.springframework.boot.context.embedded.ServletContextInitializer
;
import
org.springframework.boot.context.embedded.ServletContextInitializer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
atLeastOnce
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
/**
* Tests for {@link ServerProperties}.
* Tests for {@link ServerProperties}.
*
*
...
@@ -261,12 +261,7 @@ public class ServerPropertiesTests {
...
@@ -261,12 +261,7 @@ public class ServerPropertiesTests {
@Test
@Test
public
void
defaultTomcatRemoteIpValve
()
throws
Exception
{
public
void
defaultTomcatRemoteIpValve
()
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
// Since 1.3.0 no need to explicitly set header names
// Since 1.1.7 you need to specify at least the protocol and ip properties
map
.
put
(
"server.tomcat.protocol_header"
,
"x-forwarded-proto"
);
map
.
put
(
"server.tomcat.remote_ip_header"
,
"x-forwarded-for"
);
bindProperties
(
map
);
TomcatEmbeddedServletContainerFactory
container
=
new
TomcatEmbeddedServletContainerFactory
();
TomcatEmbeddedServletContainerFactory
container
=
new
TomcatEmbeddedServletContainerFactory
();
this
.
properties
.
customize
(
container
);
this
.
properties
.
customize
(
container
);
...
...
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