From efc37d6f6e4bbf40ded32e7c9d9d90386b43cc84 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Wed, 19 Aug 2026 10:20:05 +0530 Subject: [PATCH 01/16] Implement the forwarded headers --- spring-boot-modules/spring-boot-5/Dockerfile | 7 ++++ .../spring-boot-5/docker-compose.yml | 20 +++++++++++ .../spring-boot-5/nginx/nginx.conf | 29 ++++++++++++++++ .../ForwardHeadersApplication.java | 12 +++++++ .../forwardheaders/HealthController.java | 32 ++++++++++++++++++ .../src/main/resources/application.yml | 24 ++++++++++++++ .../HealthControllerLiveTest.java | 33 +++++++++++++++++++ 7 files changed, 157 insertions(+) create mode 100644 spring-boot-modules/spring-boot-5/Dockerfile create mode 100644 spring-boot-modules/spring-boot-5/docker-compose.yml create mode 100644 spring-boot-modules/spring-boot-5/nginx/nginx.conf create mode 100644 spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/ForwardHeadersApplication.java create mode 100644 spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/HealthController.java create mode 100644 spring-boot-modules/spring-boot-5/src/main/resources/application.yml create mode 100644 spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/HealthControllerLiveTest.java diff --git a/spring-boot-modules/spring-boot-5/Dockerfile b/spring-boot-modules/spring-boot-5/Dockerfile new file mode 100644 index 000000000000..631e6fbf0163 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/Dockerfile @@ -0,0 +1,7 @@ +FROM eclipse-temurin:21-jre-alpine + +WORKDIR /app +COPY target/spring-boot-5-0.0.1-SNAPSHOT.jar backend-app.jar + +EXPOSE 8081 +ENTRYPOINT ["java", "-jar", "backend-app.jar"] \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-5/docker-compose.yml b/spring-boot-modules/spring-boot-5/docker-compose.yml new file mode 100644 index 000000000000..914b14fff631 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/docker-compose.yml @@ -0,0 +1,20 @@ +services: + backend-app: + build: + context: . + dockerfile: Dockerfile + container_name: backend-app + expose: + - "8081" + + nginx: + image: nginx:1.31.3-alpine + container_name: nginx-proxy + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx/certs:/etc/nginx/certs:ro + ports: + - "443:443" + depends_on: + - backend-app + diff --git a/spring-boot-modules/spring-boot-5/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/nginx/nginx.conf new file mode 100644 index 000000000000..99f5ed99975c --- /dev/null +++ b/spring-boot-modules/spring-boot-5/nginx/nginx.conf @@ -0,0 +1,29 @@ +worker_processes auto; + +events { + worker_connections 1024; +} + +http { + server { + listen 443 ssl; + server_name api.example.com; + + ssl_certificate /etc/nginx/certs/api.example.com.crt; + ssl_certificate_key /etc/nginx/certs/api.example.com.key; + ssl_protocols TLSv1.2 TLSv1.3; + + location / { + proxy_pass http://backend-app:8081; + + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header Forwarded "for=$remote_addr;by=$server_addr;host=$host;port=$server_port;proto=$scheme"; + + proxy_http_version 1.1; + proxy_set_header Connection ""; + } + } +} diff --git a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/ForwardHeadersApplication.java b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/ForwardHeadersApplication.java new file mode 100644 index 000000000000..ce1e608f1b89 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/ForwardHeadersApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.forwardheaders; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication(scanBasePackages = "com.baeldung.forwardheaders") +public class ForwardHeadersApplication { + + public static void main(String[] args) { + SpringApplication.run(ForwardHeadersApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/HealthController.java b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/HealthController.java new file mode 100644 index 000000000000..32b174784ea3 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/HealthController.java @@ -0,0 +1,32 @@ +package com.baeldung.forwardheaders; + +import jakarta.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +@RestController +public class HealthController { + private static final Logger LOGGER = LoggerFactory.getLogger(HealthController.class); + + @GetMapping("/health") + public ResponseEntity getHealth(HttpServletRequest request) { + LOGGER.info(""" + scheme : {} + Remote Host IP : {} + Remote Port : {} + Server Name : {} + Server Port : {} + Request URL : {}""", request.getScheme(), request.getRemoteHost(), request.getRemotePort(), request.getServerName(), request.getServerPort(), + ServletUriComponentsBuilder.fromRequest(request) + .build() + .toUriString()); + + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/spring-boot-modules/spring-boot-5/src/main/resources/application.yml b/spring-boot-modules/spring-boot-5/src/main/resources/application.yml new file mode 100644 index 000000000000..6c3723ce0d8e --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/main/resources/application.yml @@ -0,0 +1,24 @@ +server: + port: 8081 + #forward-headers-strategy: NONE + #forward-headers-strategy: FRAMEWORK + forward-headers-strategy: NATIVE + tomcat: + remoteip: + remote-ip-header: X-Forwarded-For + protocol-header: X-Forwarded-Proto + host-header: X-Forwarded-Host + port-header: X-Forwarded-Port + trusted-proxies: 172\.(1[7-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3} + accesslog: + enabled: true + request-attributes-enabled: true + directory: /app/logs + prefix: access_log + suffix: .log + pattern: '%h %l %u %t "%r" %s %b "%{X-Forwarded-Host}i" "%{X-Forwarded-For}i" "%{X-Forwarded-Proto}i" "%{Forwarded}i"' + rotate: false + +spring: + application: + name: backend-app diff --git a/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/HealthControllerLiveTest.java b/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/HealthControllerLiveTest.java new file mode 100644 index 000000000000..e9f0d175783b --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/HealthControllerLiveTest.java @@ -0,0 +1,33 @@ +package com.baeldung.forwardheaders; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.web.servlet.client.RestTestClient;; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class HealthControllerLiveTest { + + private RestTestClient restTestClient; + + @LocalServerPort + private int port; + + @BeforeEach + void setUp() { + restTestClient = RestTestClient + .bindToServer() + .baseUrl("http://localhost:" + port) + .build(); + } + + @Test + void givenProductExists_whenGetProductIsCalledWithHeaderVersion1_thenReturnValidProduct() { + restTestClient.get() + .uri("/health") + .exchange() + .expectStatus().isOk() + .expectBody().isEmpty(); + } +} From 42fee5fa33001969a4df6bbd812ee3309f30de90 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Wed, 19 Aug 2026 10:56:26 +0530 Subject: [PATCH 02/16] refactor --- spring-boot-modules/spring-boot-5/docker-compose.yml | 4 ++-- .../spring-boot-5/{ => src/test/resources}/nginx/nginx.conf | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename spring-boot-modules/spring-boot-5/{ => src/test/resources}/nginx/nginx.conf (100%) diff --git a/spring-boot-modules/spring-boot-5/docker-compose.yml b/spring-boot-modules/spring-boot-5/docker-compose.yml index 914b14fff631..0a87810c9f26 100644 --- a/spring-boot-modules/spring-boot-5/docker-compose.yml +++ b/spring-boot-modules/spring-boot-5/docker-compose.yml @@ -11,8 +11,8 @@ services: image: nginx:1.31.3-alpine container_name: nginx-proxy volumes: - - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - - ./nginx/certs:/etc/nginx/certs:ro + - ./src/test/resources/nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./src/test/resources/nginx/certs:/etc/nginx/certs:ro ports: - "443:443" depends_on: diff --git a/spring-boot-modules/spring-boot-5/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/nginx/nginx.conf similarity index 100% rename from spring-boot-modules/spring-boot-5/nginx/nginx.conf rename to spring-boot-modules/spring-boot-5/src/test/resources/nginx/nginx.conf From 94c13d9d89f8901c2059e6cfc6537b5264e4662a Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Wed, 19 Aug 2026 20:32:18 +0530 Subject: [PATCH 03/16] refactor --- .../{HealthController.java => TestController.java} | 8 ++++---- ...ontrollerLiveTest.java => TestControllerLiveTest.java} | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) rename spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/{HealthController.java => TestController.java} (86%) rename spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/{HealthControllerLiveTest.java => TestControllerLiveTest.java} (93%) diff --git a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/HealthController.java b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java similarity index 86% rename from spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/HealthController.java rename to spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java index 32b174784ea3..8e4e10a1be31 100644 --- a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/HealthController.java +++ b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java @@ -11,11 +11,11 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder; @RestController -public class HealthController { - private static final Logger LOGGER = LoggerFactory.getLogger(HealthController.class); +public class TestController { + private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class); - @GetMapping("/health") - public ResponseEntity getHealth(HttpServletRequest request) { + @GetMapping("/test") + public ResponseEntity test(HttpServletRequest request) { LOGGER.info(""" scheme : {} Remote Host IP : {} diff --git a/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/HealthControllerLiveTest.java b/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/TestControllerLiveTest.java similarity index 93% rename from spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/HealthControllerLiveTest.java rename to spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/TestControllerLiveTest.java index e9f0d175783b..b8dd71c03f7c 100644 --- a/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/HealthControllerLiveTest.java +++ b/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/TestControllerLiveTest.java @@ -7,7 +7,7 @@ import org.springframework.test.web.servlet.client.RestTestClient;; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -class HealthControllerLiveTest { +class TestControllerLiveTest { private RestTestClient restTestClient; @@ -25,7 +25,7 @@ void setUp() { @Test void givenProductExists_whenGetProductIsCalledWithHeaderVersion1_thenReturnValidProduct() { restTestClient.get() - .uri("/health") + .uri("/test") .exchange() .expectStatus().isOk() .expectBody().isEmpty(); From 1b270d86d2776c923fc45671654632bb0237f902 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Wed, 19 Aug 2026 21:19:06 +0530 Subject: [PATCH 04/16] refactor files in test --- .../{ => src/test/resources/docker}/Dockerfile | 0 .../{ => src/test/resources/docker}/docker-compose.yml | 8 ++++---- .../src/test/resources/{ => docker}/nginx/nginx.conf | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename spring-boot-modules/spring-boot-5/{ => src/test/resources/docker}/Dockerfile (100%) rename spring-boot-modules/spring-boot-5/{ => src/test/resources/docker}/docker-compose.yml (57%) rename spring-boot-modules/spring-boot-5/src/test/resources/{ => docker}/nginx/nginx.conf (100%) diff --git a/spring-boot-modules/spring-boot-5/Dockerfile b/spring-boot-modules/spring-boot-5/src/test/resources/docker/Dockerfile similarity index 100% rename from spring-boot-modules/spring-boot-5/Dockerfile rename to spring-boot-modules/spring-boot-5/src/test/resources/docker/Dockerfile diff --git a/spring-boot-modules/spring-boot-5/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/docker-compose.yml similarity index 57% rename from spring-boot-modules/spring-boot-5/docker-compose.yml rename to spring-boot-modules/spring-boot-5/src/test/resources/docker/docker-compose.yml index 0a87810c9f26..92eea2a44839 100644 --- a/spring-boot-modules/spring-boot-5/docker-compose.yml +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/docker-compose.yml @@ -1,8 +1,8 @@ services: backend-app: build: - context: . - dockerfile: Dockerfile + context: ../../../../ + dockerfile: ./src/test/resources/docker/Dockerfile container_name: backend-app expose: - "8081" @@ -11,8 +11,8 @@ services: image: nginx:1.31.3-alpine container_name: nginx-proxy volumes: - - ./src/test/resources/nginx/nginx.conf:/etc/nginx/nginx.conf:ro - - ./src/test/resources/nginx/certs:/etc/nginx/certs:ro + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx/certs:/etc/nginx/certs:ro ports: - "443:443" depends_on: diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf similarity index 100% rename from spring-boot-modules/spring-boot-5/src/test/resources/nginx/nginx.conf rename to spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf From f26887be1738b03e99baaab385b809130d4c0468 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Thu, 20 Aug 2026 08:20:59 +0530 Subject: [PATCH 05/16] update controller --- .../java/com/baeldung/forwardheaders/TestController.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java index 8e4e10a1be31..5367b9680945 100644 --- a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java +++ b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java @@ -12,6 +12,7 @@ @RestController public class TestController { + private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class); @GetMapping("/test") @@ -23,9 +24,7 @@ public ResponseEntity test(HttpServletRequest request) { Server Name : {} Server Port : {} Request URL : {}""", request.getScheme(), request.getRemoteHost(), request.getRemotePort(), request.getServerName(), request.getServerPort(), - ServletUriComponentsBuilder.fromRequest(request) - .build() - .toUriString()); + request.getRequestURL()); return new ResponseEntity<>(HttpStatus.OK); } From 081b8e06f1569dfc95efd32755aa18e43e83139a Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Thu, 20 Aug 2026 08:21:21 +0530 Subject: [PATCH 06/16] update controller --- spring-boot-modules/spring-boot-5/pom.xml | 2 +- .../main/java/com/baeldung/forwardheaders/TestController.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-5/pom.xml b/spring-boot-modules/spring-boot-5/pom.xml index 0f5fd41bf388..5c73efeb00bb 100644 --- a/spring-boot-modules/spring-boot-5/pom.xml +++ b/spring-boot-modules/spring-boot-5/pom.xml @@ -37,7 +37,7 @@ org.springframework.boot spring-boot-maven-plugin - com.baeldung.apiversions.header.ExampleApplication + com.baeldung.forwardheaders.ForwardHeadersApplication diff --git a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java index 5367b9680945..2a1718efa3e3 100644 --- a/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java +++ b/spring-boot-modules/spring-boot-5/src/main/java/com/baeldung/forwardheaders/TestController.java @@ -8,7 +8,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.support.ServletUriComponentsBuilder; @RestController public class TestController { From 1adc44a046f6e8afe51ac02dff997e6734c73685 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Thu, 20 Aug 2026 08:23:34 +0530 Subject: [PATCH 07/16] revert pom --- spring-boot-modules/spring-boot-5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-5/pom.xml b/spring-boot-modules/spring-boot-5/pom.xml index 5c73efeb00bb..32600ba8e63b 100644 --- a/spring-boot-modules/spring-boot-5/pom.xml +++ b/spring-boot-modules/spring-boot-5/pom.xml @@ -37,7 +37,7 @@ org.springframework.boot spring-boot-maven-plugin - com.baeldung.forwardheaders.ForwardHeadersApplication + com.baeldung.apiversions.header.ExampleApplication From 9e435fe3c9f8327e163024079865c5d1c17fa1bd Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Thu, 20 Aug 2026 10:04:13 +0530 Subject: [PATCH 08/16] revert pom --- spring-boot-modules/spring-boot-5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-5/pom.xml b/spring-boot-modules/spring-boot-5/pom.xml index 32600ba8e63b..0f5fd41bf388 100644 --- a/spring-boot-modules/spring-boot-5/pom.xml +++ b/spring-boot-modules/spring-boot-5/pom.xml @@ -37,7 +37,7 @@ org.springframework.boot spring-boot-maven-plugin - com.baeldung.apiversions.header.ExampleApplication + com.baeldung.apiversions.header.ExampleApplication From 6e15b6b82f40e99bb58046d8ab55bdd8f38561f0 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Thu, 20 Aug 2026 11:52:33 +0530 Subject: [PATCH 09/16] refactor test name --- .../com/baeldung/forwardheaders/TestControllerLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/TestControllerLiveTest.java b/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/TestControllerLiveTest.java index b8dd71c03f7c..31b6e568f6aa 100644 --- a/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/TestControllerLiveTest.java +++ b/spring-boot-modules/spring-boot-5/src/test/java/com/baeldung/forwardheaders/TestControllerLiveTest.java @@ -23,7 +23,7 @@ void setUp() { } @Test - void givenProductExists_whenGetProductIsCalledWithHeaderVersion1_thenReturnValidProduct() { + void givenTestApiIsRunning_whenGetTestIsCalled_thenReturnOkWithNoContent() { restTestClient.get() .uri("/test") .exchange() From 3243b025101e4bcf1ab5b25018b556f91b2934df Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Tue, 25 Aug 2026 10:50:02 +0530 Subject: [PATCH 10/16] update config in backend app and nginx --- .../spring-boot-5/src/main/resources/application.yml | 2 +- .../src/test/resources/docker/nginx/nginx.conf | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-boot-modules/spring-boot-5/src/main/resources/application.yml b/spring-boot-modules/spring-boot-5/src/main/resources/application.yml index 6c3723ce0d8e..805317120e63 100644 --- a/spring-boot-modules/spring-boot-5/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-5/src/main/resources/application.yml @@ -9,7 +9,7 @@ server: protocol-header: X-Forwarded-Proto host-header: X-Forwarded-Host port-header: X-Forwarded-Port - trusted-proxies: 172\.(1[7-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3} + trusted-proxies: 172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3} accesslog: enabled: true request-attributes-enabled: true diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf index 99f5ed99975c..e4b178752220 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf @@ -13,14 +13,16 @@ http { ssl_certificate_key /etc/nginx/certs/api.example.com.key; ssl_protocols TLSv1.2 TLSv1.3; - location / { - proxy_pass http://backend-app:8081; + location /api/ { + proxy_pass http://backend-app:8081/; + proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header Forwarded "for=$remote_addr;by=$server_addr;host=$host;port=$server_port;proto=$scheme"; + proxy_set_header X-Forwarded-Prefix /api; + proxy_set_header Forwarded "for=$remote_addr;by=$server_addr;host=$host;proto=$scheme"; proxy_http_version 1.1; proxy_set_header Connection ""; From 41a9b4defa55072f75843d98a6b55499b0e4bbd0 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Tue, 25 Aug 2026 11:10:18 +0530 Subject: [PATCH 11/16] update config in nginx --- .../spring-boot-5/src/test/resources/docker/nginx/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf index e4b178752220..dd4e9a70c8fc 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf @@ -13,7 +13,7 @@ http { ssl_certificate_key /etc/nginx/certs/api.example.com.key; ssl_protocols TLSv1.2 TLSv1.3; - location /api/ { + location /myapp/ { proxy_pass http://backend-app:8081/; proxy_set_header Host $host; @@ -21,7 +21,7 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header X-Forwarded-Prefix /api; + proxy_set_header X-Forwarded-Prefix /myapp; proxy_set_header Forwarded "for=$remote_addr;by=$server_addr;host=$host;proto=$scheme"; proxy_http_version 1.1; From c3d35494a90521f77803bb5e2ae2ec30750c8639 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Tue, 25 Aug 2026 11:24:02 +0530 Subject: [PATCH 12/16] update config --- .../spring-boot-5/src/test/resources/docker/nginx/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf index dd4e9a70c8fc..6817fe8e8227 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf @@ -18,7 +18,7 @@ http { proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Prefix /myapp; From abed605c1ba8df8196d92b4b62395119ff2a953d Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Wed, 26 Aug 2026 13:50:49 +0530 Subject: [PATCH 13/16] update configs and docker --- .../main/resources/application-framework.yml | 2 + .../src/main/resources/application-native.yml | 17 ++++++++ .../src/main/resources/application-none.yml | 2 + .../src/main/resources/application.yml | 20 +--------- .../docker/{ => default}/docker-compose.yml | 5 ++- .../docker/{ => default}/nginx/nginx.conf | 3 +- .../docker/framework/docker-compose.yml | 22 +++++++++++ .../docker/framework/nginx/nginx.conf | 39 +++++++++++++++++++ .../docker/native/docker-compose.yml | 22 +++++++++++ .../resources/docker/none/docker-compose.yml | 23 +++++++++++ .../resources/docker/none/nginx/nginx.conf | 32 +++++++++++++++ 11 files changed, 166 insertions(+), 21 deletions(-) create mode 100644 spring-boot-modules/spring-boot-5/src/main/resources/application-framework.yml create mode 100644 spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml create mode 100644 spring-boot-modules/spring-boot-5/src/main/resources/application-none.yml rename spring-boot-modules/spring-boot-5/src/test/resources/docker/{ => default}/docker-compose.yml (83%) rename spring-boot-modules/spring-boot-5/src/test/resources/docker/{ => default}/nginx/nginx.conf (89%) create mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml create mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/nginx/nginx.conf create mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml create mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml create mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf diff --git a/spring-boot-modules/spring-boot-5/src/main/resources/application-framework.yml b/spring-boot-modules/spring-boot-5/src/main/resources/application-framework.yml new file mode 100644 index 000000000000..2a628f82f585 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/main/resources/application-framework.yml @@ -0,0 +1,2 @@ +server: + forward-headers-strategy: FRAMEWORK \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml b/spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml new file mode 100644 index 000000000000..962bfd8b8e8a --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml @@ -0,0 +1,17 @@ +server: + forward-headers-strategy: NATIVE + tomcat: + remoteip: + remote-ip-header: X-Forwarded-For + protocol-header: X-Forwarded-Proto + host-header: X-Forwarded-Host + port-header: X-Forwarded-Port + trusted-proxies: 172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3} + accesslog: + enabled: true + request-attributes-enabled: true + directory: /app/logs + prefix: access_log + suffix: .log + pattern: '%h %l %u %t "%r" %s %b "%{X-Forwarded-Host}i" "%{X-Forwarded-For}i" "%{X-Forwarded-Proto}i" "%{Forwarded}i"' + rotate: false diff --git a/spring-boot-modules/spring-boot-5/src/main/resources/application-none.yml b/spring-boot-modules/spring-boot-5/src/main/resources/application-none.yml new file mode 100644 index 000000000000..32daac51472f --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/main/resources/application-none.yml @@ -0,0 +1,2 @@ +server: + forward-headers-strategy: NONE diff --git a/spring-boot-modules/spring-boot-5/src/main/resources/application.yml b/spring-boot-modules/spring-boot-5/src/main/resources/application.yml index 805317120e63..8cb5da84c64c 100644 --- a/spring-boot-modules/spring-boot-5/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-5/src/main/resources/application.yml @@ -1,24 +1,6 @@ server: port: 8081 - #forward-headers-strategy: NONE - #forward-headers-strategy: FRAMEWORK - forward-headers-strategy: NATIVE - tomcat: - remoteip: - remote-ip-header: X-Forwarded-For - protocol-header: X-Forwarded-Proto - host-header: X-Forwarded-Host - port-header: X-Forwarded-Port - trusted-proxies: 172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3} - accesslog: - enabled: true - request-attributes-enabled: true - directory: /app/logs - prefix: access_log - suffix: .log - pattern: '%h %l %u %t "%r" %s %b "%{X-Forwarded-Host}i" "%{X-Forwarded-For}i" "%{X-Forwarded-Proto}i" "%{Forwarded}i"' - rotate: false spring: application: - name: backend-app + name: backend-app \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/docker-compose.yml similarity index 83% rename from spring-boot-modules/spring-boot-5/src/test/resources/docker/docker-compose.yml rename to spring-boot-modules/spring-boot-5/src/test/resources/docker/default/docker-compose.yml index 92eea2a44839..fb4401f64ad3 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/docker-compose.yml +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/docker-compose.yml @@ -1,12 +1,15 @@ services: backend-app: build: - context: ../../../../ + context: ../../../../../ dockerfile: ./src/test/resources/docker/Dockerfile container_name: backend-app + environment: + - SPRING_PROFILES_ACTIVE= expose: - "8081" + nginx: image: nginx:1.31.3-alpine container_name: nginx-proxy diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/nginx/nginx.conf similarity index 89% rename from spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf rename to spring-boot-modules/spring-boot-5/src/test/resources/docker/default/nginx/nginx.conf index 6817fe8e8227..bccb9ac3fb96 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/nginx/nginx.conf +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/nginx/nginx.conf @@ -5,6 +5,7 @@ events { } http { + server { listen 443 ssl; server_name api.example.com; @@ -17,12 +18,12 @@ http { proxy_pass http://backend-app:8081/; proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Prefix /myapp; - proxy_set_header Forwarded "for=$remote_addr;by=$server_addr;host=$host;proto=$scheme"; proxy_http_version 1.1; proxy_set_header Connection ""; diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml new file mode 100644 index 000000000000..ba8316f7317f --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml @@ -0,0 +1,22 @@ +services: + backend-app: + build: + context: ../../../../../ + dockerfile: ./src/test/resources/docker/Dockerfile + container_name: backend-app + environment: + - SPRING_PROFILES_ACTIVE=framework + expose: + - "8081" + + nginx: + image: nginx:1.31.3-alpine + container_name: nginx-proxy + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx/certs:/etc/nginx/certs:ro + ports: + - "443:443" + depends_on: + - backend-app + diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/nginx/nginx.conf new file mode 100644 index 000000000000..700ce34861ff --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/nginx/nginx.conf @@ -0,0 +1,39 @@ +worker_processes auto; + +events { + worker_connections 1024; +} + +http { + + map $remote_addr $forwarded_for { + ~: "\"[$remote_addr]:$remote_port\""; + default "\"$remote_addr:$remote_port\""; + } + + map $server_addr $forwarded_by { + ~: "\"[$server_addr]:$server_port\""; + default "\"$server_addr:$server_port\""; + } + + server { + listen 443 ssl; + server_name api.example.com; + + ssl_certificate /etc/nginx/certs/api.example.com.crt; + ssl_certificate_key /etc/nginx/certs/api.example.com.key; + ssl_protocols TLSv1.2 TLSv1.3; + + location /myapp/ { + proxy_pass http://backend-app:8081/; + + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Prefix /myapp; + + proxy_set_header Forwarded "for=$forwarded_for;by=$forwarded_by;host=$host;proto=$scheme"; + + proxy_http_version 1.1; + proxy_set_header Connection ""; + } + } +} diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml new file mode 100644 index 000000000000..041c3ace3e1e --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml @@ -0,0 +1,22 @@ +services: + backend-app: + build: + context: ../../../../../ + dockerfile: ./src/test/resources/docker/Dockerfile + container_name: backend-app + environment: + - SPRING_PROFILES_ACTIVE=native + expose: + - "8081" + + nginx: + image: nginx:1.31.3-alpine + container_name: nginx-proxy + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx/certs:/etc/nginx/certs:ro + ports: + - "443:443" + depends_on: + - backend-app + diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml new file mode 100644 index 000000000000..3b4d55a1cfb3 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml @@ -0,0 +1,23 @@ +services: + backend-app: + build: + context: ../../../../../ + dockerfile: ./src/test/resources/docker/Dockerfile + container_name: backend-app + environment: + - SPRING_PROFILES_ACTIVE=none + expose: + - "8081" + + + nginx: + image: nginx:1.31.3-alpine + container_name: nginx-proxy + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx/certs:/etc/nginx/certs:ro + ports: + - "443:443" + depends_on: + - backend-app + diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf new file mode 100644 index 000000000000..bccb9ac3fb96 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf @@ -0,0 +1,32 @@ +worker_processes auto; + +events { + worker_connections 1024; +} + +http { + + server { + listen 443 ssl; + server_name api.example.com; + + ssl_certificate /etc/nginx/certs/api.example.com.crt; + ssl_certificate_key /etc/nginx/certs/api.example.com.key; + ssl_protocols TLSv1.2 TLSv1.3; + + location /myapp/ { + proxy_pass http://backend-app:8081/; + + proxy_set_header Host $host; + + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header X-Forwarded-Prefix /myapp; + + proxy_http_version 1.1; + proxy_set_header Connection ""; + } + } +} From 37a190a8d93b2c1fda44720a5a3bdacfeedb7dbb Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Wed, 26 Aug 2026 14:44:19 +0530 Subject: [PATCH 14/16] update configs and docker --- .../src/main/resources/application-native.yml | 4 +-- .../resources/docker/native/nginx/nginx.conf | 32 +++++++++++++++++++ .../resources/docker/none/nginx/nginx.conf | 1 - 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf diff --git a/spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml b/spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml index 962bfd8b8e8a..2c01898f85b4 100644 --- a/spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml +++ b/spring-boot-modules/spring-boot-5/src/main/resources/application-native.yml @@ -13,5 +13,5 @@ server: directory: /app/logs prefix: access_log suffix: .log - pattern: '%h %l %u %t "%r" %s %b "%{X-Forwarded-Host}i" "%{X-Forwarded-For}i" "%{X-Forwarded-Proto}i" "%{Forwarded}i"' - rotate: false + pattern: '%h %l %u %t "%r" %s %b "%{X-Forwarded-Host}i" "%{X-Forwarded-For}i" "%{X-Forwarded-Proto}i"' + rotate: false \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf new file mode 100644 index 000000000000..bccb9ac3fb96 --- /dev/null +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf @@ -0,0 +1,32 @@ +worker_processes auto; + +events { + worker_connections 1024; +} + +http { + + server { + listen 443 ssl; + server_name api.example.com; + + ssl_certificate /etc/nginx/certs/api.example.com.crt; + ssl_certificate_key /etc/nginx/certs/api.example.com.key; + ssl_protocols TLSv1.2 TLSv1.3; + + location /myapp/ { + proxy_pass http://backend-app:8081/; + + proxy_set_header Host $host; + + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header X-Forwarded-Prefix /myapp; + + proxy_http_version 1.1; + proxy_set_header Connection ""; + } + } +} diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf index bccb9ac3fb96..75b9e4e42fa7 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf @@ -18,7 +18,6 @@ http { proxy_pass http://backend-app:8081/; proxy_set_header Host $host; - proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $host; From c5091beaea79c9028ef13d383856e0e363fafec1 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Thu, 27 Aug 2026 09:13:00 +0530 Subject: [PATCH 15/16] update configs and docker --- .../docker/default/docker-compose.yml | 4 +-- .../resources/docker/default/nginx/nginx.conf | 32 ------------------- .../docker/framework/docker-compose.yml | 4 +-- .../docker/native/docker-compose.yml | 4 +-- .../resources/docker/native/nginx/nginx.conf | 32 ------------------- .../resources/docker/none/docker-compose.yml | 4 +-- .../resources/docker/none/nginx/nginx.conf | 31 ------------------ .../{docker/framework => }/nginx/nginx.conf | 5 +++ 8 files changed, 13 insertions(+), 103 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/default/nginx/nginx.conf delete mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf delete mode 100644 spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf rename spring-boot-modules/spring-boot-5/src/test/resources/{docker/framework => }/nginx/nginx.conf (81%) diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/docker-compose.yml index fb4401f64ad3..fcff2f3d5cbb 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/docker-compose.yml +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/docker-compose.yml @@ -14,8 +14,8 @@ services: image: nginx:1.31.3-alpine container_name: nginx-proxy volumes: - - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - - ./nginx/certs:/etc/nginx/certs:ro + - ../../nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ../../nginx/certs:/etc/nginx/certs:ro ports: - "443:443" depends_on: diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/nginx/nginx.conf deleted file mode 100644 index bccb9ac3fb96..000000000000 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/default/nginx/nginx.conf +++ /dev/null @@ -1,32 +0,0 @@ -worker_processes auto; - -events { - worker_connections 1024; -} - -http { - - server { - listen 443 ssl; - server_name api.example.com; - - ssl_certificate /etc/nginx/certs/api.example.com.crt; - ssl_certificate_key /etc/nginx/certs/api.example.com.key; - ssl_protocols TLSv1.2 TLSv1.3; - - location /myapp/ { - proxy_pass http://backend-app:8081/; - - proxy_set_header Host $host; - - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header X-Forwarded-Prefix /myapp; - - proxy_http_version 1.1; - proxy_set_header Connection ""; - } - } -} diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml index ba8316f7317f..309e0ea10aef 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/docker-compose.yml @@ -13,8 +13,8 @@ services: image: nginx:1.31.3-alpine container_name: nginx-proxy volumes: - - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - - ./nginx/certs:/etc/nginx/certs:ro + - ../../nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ../../nginx/certs:/etc/nginx/certs:ro ports: - "443:443" depends_on: diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml index 041c3ace3e1e..166b51ceecbc 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/docker-compose.yml @@ -13,8 +13,8 @@ services: image: nginx:1.31.3-alpine container_name: nginx-proxy volumes: - - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - - ./nginx/certs:/etc/nginx/certs:ro + - ../../nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ../../nginx/certs:/etc/nginx/certs:ro ports: - "443:443" depends_on: diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf deleted file mode 100644 index bccb9ac3fb96..000000000000 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/native/nginx/nginx.conf +++ /dev/null @@ -1,32 +0,0 @@ -worker_processes auto; - -events { - worker_connections 1024; -} - -http { - - server { - listen 443 ssl; - server_name api.example.com; - - ssl_certificate /etc/nginx/certs/api.example.com.crt; - ssl_certificate_key /etc/nginx/certs/api.example.com.key; - ssl_protocols TLSv1.2 TLSv1.3; - - location /myapp/ { - proxy_pass http://backend-app:8081/; - - proxy_set_header Host $host; - - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header X-Forwarded-Prefix /myapp; - - proxy_http_version 1.1; - proxy_set_header Connection ""; - } - } -} diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml index 3b4d55a1cfb3..f7936ef74b0a 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml +++ b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/docker-compose.yml @@ -14,8 +14,8 @@ services: image: nginx:1.31.3-alpine container_name: nginx-proxy volumes: - - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - - ./nginx/certs:/etc/nginx/certs:ro + - ../../nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ../../nginx/certs:/etc/nginx/certs:ro ports: - "443:443" depends_on: diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf deleted file mode 100644 index 75b9e4e42fa7..000000000000 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/none/nginx/nginx.conf +++ /dev/null @@ -1,31 +0,0 @@ -worker_processes auto; - -events { - worker_connections 1024; -} - -http { - - server { - listen 443 ssl; - server_name api.example.com; - - ssl_certificate /etc/nginx/certs/api.example.com.crt; - ssl_certificate_key /etc/nginx/certs/api.example.com.key; - ssl_protocols TLSv1.2 TLSv1.3; - - location /myapp/ { - proxy_pass http://backend-app:8081/; - - proxy_set_header Host $host; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - proxy_set_header X-Forwarded-Prefix /myapp; - - proxy_http_version 1.1; - proxy_set_header Connection ""; - } - } -} diff --git a/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/nginx/nginx.conf b/spring-boot-modules/spring-boot-5/src/test/resources/nginx/nginx.conf similarity index 81% rename from spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/nginx/nginx.conf rename to spring-boot-modules/spring-boot-5/src/test/resources/nginx/nginx.conf index 700ce34861ff..2d386a012153 100644 --- a/spring-boot-modules/spring-boot-5/src/test/resources/docker/framework/nginx/nginx.conf +++ b/spring-boot-modules/spring-boot-5/src/test/resources/nginx/nginx.conf @@ -28,6 +28,11 @@ http { proxy_pass http://backend-app:8081/; proxy_set_header Host $host; + + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Prefix /myapp; proxy_set_header Forwarded "for=$forwarded_for;by=$forwarded_by;host=$host;proto=$scheme"; From f6002dd8fff6a0b885042bee55b9a48639fda9c4 Mon Sep 17 00:00:00 2001 From: saikatcse03 Date: Thu, 27 Aug 2026 12:39:36 +0530 Subject: [PATCH 16/16] update the version --- spring-boot-modules/spring-boot-5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-5/pom.xml b/spring-boot-modules/spring-boot-5/pom.xml index 0f5fd41bf388..a10f11b12f04 100644 --- a/spring-boot-modules/spring-boot-5/pom.xml +++ b/spring-boot-modules/spring-boot-5/pom.xml @@ -57,7 +57,7 @@ - 4.0.2 + 4.1.1 6.0.0 1.5.18 3.0.0-M7