Skip to content

Commit 0dc46a2

Browse files
committed
Drop protocolHeader and remoteIpHeader defaults
The `protocolHeader` and `remoteIpHeader` no longer have default values and must be opt-in. Fixes gh-1624
1 parent 72ef1d6 commit 0dc46a2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ public static class Tomcat {
207207
+ "169\\.254\\.\\d{1,3}\\.\\d{1,3}|" // 169.254/16
208208
+ "127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"; // 127/8
209209

210-
private String protocolHeader = "x-forwarded-proto";
210+
private String protocolHeader;
211211

212-
private String remoteIpHeader = "x-forwarded-for";
212+
private String remoteIpHeader;
213213

214214
private File basedir;
215215

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java

+6
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ public void disableTomcatRemoteIpValve() throws Exception {
147147

148148
@Test
149149
public void defaultTomcatRemoteIpValve() throws Exception {
150+
Map<String, String> map = new HashMap<String, String>();
151+
// Since 1.1.7 you need to specify at least the protocol and ip properties
152+
map.put("server.tomcat.protocol_header", "x-forwarded-proto");
153+
map.put("server.tomcat.remote_ip_header", "x-forwarded-for");
154+
bindProperties(map);
155+
150156
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
151157
this.properties.customize(container);
152158

0 commit comments

Comments
 (0)