Skip to content

Commit 2e86a6f

Browse files
committed
Merge branch '1.5.x' into 2.0.x
2 parents 9b1e74b + 0bd7c8a commit 2e86a6f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,16 @@ public static class Tomcat {
372372
private final Accesslog accesslog = new Accesslog();
373373

374374
/**
375-
* Regular expression matching trusted IP addresses.
375+
* Regular expression that matches proxies that are to be trusted.
376376
*/
377377
private String internalProxies = "10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|" // 10/8
378378
+ "192\\.168\\.\\d{1,3}\\.\\d{1,3}|" // 192.168/16
379379
+ "169\\.254\\.\\d{1,3}\\.\\d{1,3}|" // 169.254/16
380380
+ "127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|" // 127/8
381381
+ "172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12
382382
+ "172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|"
383-
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}";
383+
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}|" //
384+
+ "0:0:0:0:0:0:0:1|::1";
384385

385386
/**
386387
* Header that holds the incoming protocol, usually named "X-Forwarded-Proto".

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.catalina.core.StandardContext;
3838
import org.apache.catalina.core.StandardEngine;
3939
import org.apache.catalina.valves.AccessLogValve;
40+
import org.apache.catalina.valves.RemoteIpValve;
4041
import org.apache.coyote.AbstractProtocol;
4142
import org.eclipse.jetty.server.HttpChannel;
4243
import org.eclipse.jetty.server.Request;
@@ -267,6 +268,12 @@ public void tomcatAccessLogRequestAttributesEnabledMatchesDefault() {
267268
.isEqualTo(new AccessLogValve().getRequestAttributesEnabled());
268269
}
269270

271+
@Test
272+
public void tomcatInternalProxiesMatchesDefault() {
273+
assertThat(this.properties.getTomcat().getInternalProxies())
274+
.isEqualTo(new RemoteIpValve().getInternalProxies());
275+
}
276+
270277
@Test
271278
public void jettyMaxHttpPostSizeMatchesDefault() throws Exception {
272279
JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0);

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ private void testRemoteIpValveConfigured() {
167167
+ "127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|" // 127/8
168168
+ "172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12
169169
+ "172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|"
170-
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}";
170+
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}|" //
171+
+ "0:0:0:0:0:0:0:1|::1";
171172
assertThat(remoteIpValve.getInternalProxies()).isEqualTo(expectedInternalProxies);
172173
}
173174

0 commit comments

Comments
 (0)