Skip to content

Commit 0bd7c8a

Browse files
committed
Align server.tomcat.internal-proxies default with RemoteIPValve's default
Closes gh-13798
1 parent 615eeee commit 0bd7c8a

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ public static class Tomcat {
610610
+ "127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|" // 127/8
611611
+ "172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12
612612
+ "172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|"
613-
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}";
613+
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}|" //
614+
+ "0:0:0:0:0:0:0:1|::1";
614615

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

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ private void testRemoteIpValveConfigured() {
579579
+ "127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|" // 127/8
580580
+ "172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12
581581
+ "172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|"
582-
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}";
582+
+ "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}|" //
583+
+ "0:0:0:0:0:0:0:1|::1";
583584
assertThat(remoteIpValve.getInternalProxies()).isEqualTo(expectedInternalProxies);
584585
}
585586

@@ -896,6 +897,12 @@ public void tomcatAccessLogRequestAttributesEnabledMatchesDefault() {
896897
.isEqualTo(new AccessLogValve().getRequestAttributesEnabled());
897898
}
898899

900+
@Test
901+
public void tomcatInternalProxiesMatchesDefault() {
902+
assertThat(this.properties.getTomcat().getInternalProxies())
903+
.isEqualTo(new RemoteIpValve().getInternalProxies());
904+
}
905+
899906
@Test
900907
public void jettyMaxHttpPostSizeMatchesDefault() throws Exception {
901908
JettyEmbeddedServletContainerFactory jettyFactory = new JettyEmbeddedServletContainerFactory(

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ content into your application; rather pick only the properties that you need.
212212
127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\
213213
172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
214214
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
215-
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
215+
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
216+
0:0:0:0:0:0:0:1|::1 # Regular expression that matches proxies that are to be trusted.
216217
server.tomcat.max-connections=10000 # Maximum number of connections that the server will accept and process at any given time.
217218
server.tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
218219
server.tomcat.max-http-post-size=2097152 # Maximum size in bytes of the HTTP post content.

0 commit comments

Comments
 (0)