From 973f9615af727c6d93777a33542df7f78dc0cfd3 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 10 Apr 2025 10:57:23 -0700 Subject: [PATCH] Align proxies with defaults from Tomcat 10.1.40 See gh-45128 --- .../boot/autoconfigure/web/ServerProperties.java | 5 ++++- .../web/embedded/TomcatWebServerFactoryCustomizerTests.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 9702d8fe72..50877ba825 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -1047,7 +1047,10 @@ public class ServerProperties { + "172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12 + "172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12 + "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12 - + "0:0:0:0:0:0:0:1|::1"; + + "0:0:0:0:0:0:0:1|" // 0:0:0:0:0:0:0:1 + + "::1|" // ::1 + + "fe[89ab]\\p{XDigit}:.*|" // + + "f[cd]\\p{XDigit}{2}+:.*"; /** * Header that holds the incoming protocol, usually named "X-Forwarded-Proto". diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java index 286ddd40ac..cc34e5359c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java @@ -386,7 +386,10 @@ class TomcatWebServerFactoryCustomizerTests { + "172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12 + "172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12 + "172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3}|" // 172.16/12 - + "0:0:0:0:0:0:0:1|::1"; + + "0:0:0:0:0:0:0:1|" // 0:0:0:0:0:0:0:1 + + "::1|" // ::1 + + "fe[89ab]\\p{XDigit}:.*|" // + + "f[cd]\\p{XDigit}{2}+:.*"; assertThat(remoteIpValve.getInternalProxies()).isEqualTo(expectedInternalProxies); }