diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/ListenerConfigBlueprint.java b/webserver/webserver/src/main/java/io/helidon/webserver/ListenerConfigBlueprint.java index 61925e90da4..c5d1f6d70e5 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/ListenerConfigBlueprint.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/ListenerConfigBlueprint.java @@ -366,6 +366,7 @@ interface ListenerConfigBlueprint { * * @return proxy support status */ + @Option.Configured @Option.Default("false") boolean enableProxyProtocol(); diff --git a/webserver/webserver/src/test/java/io/helidon/webserver/ListenerConfigTest.java b/webserver/webserver/src/test/java/io/helidon/webserver/ListenerConfigTest.java index 23718f0388e..067b29e1125 100644 --- a/webserver/webserver/src/test/java/io/helidon/webserver/ListenerConfigTest.java +++ b/webserver/webserver/src/test/java/io/helidon/webserver/ListenerConfigTest.java @@ -57,4 +57,24 @@ void testSpecificListenerConfigFromConfigFile() { assertThat(listenerConfig.shutdownGracePeriod().toMillis(), is(2000L)); } + @Test + void testEnableProxyProtocolConfig() { + Config config = Config.create(); + + // default is false in default socket + var webServerConfig = WebServer.builder().config(config.get("server")).buildPrototype(); + assertThat(webServerConfig.enableProxyProtocol(), is(false)); + ListenerConfig otherConfig = webServerConfig.sockets().get("other"); + assertThat(otherConfig.enableProxyProtocol(), is(false)); + + // set to true in default socket + var webServerConfig2 = WebServer.builder().config(config.get("server2")).buildPrototype(); + assertThat(webServerConfig2.enableProxyProtocol(), is(true)); + + // set to true in non-default socket + var webServerConfig3 = WebServer.builder().config(config.get("server3")).buildPrototype(); + assertThat(webServerConfig3.enableProxyProtocol(), is(false)); + ListenerConfig graceConfig = webServerConfig3.sockets().get("grace"); + assertThat(graceConfig.enableProxyProtocol(), is(true)); + } } diff --git a/webserver/webserver/src/test/resources/application.yaml b/webserver/webserver/src/test/resources/application.yaml index ba46fec6787..1fe789becc3 100644 --- a/webserver/webserver/src/test/resources/application.yaml +++ b/webserver/webserver/src/test/resources/application.yaml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2023 Oracle and/or its affiliates. +# Copyright (c) 2022, 2024 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ server2: port: 8079 host: 127.0.0.1 shutdown-grace-period: PT1S + enable-proxy-protocol: true connection-providers-discover-services: false media-context: @@ -57,6 +58,7 @@ server3: sockets: - name: "grace" shutdown-grace-period: PT2S + enable-proxy-protocol: true inject: permits-dynamic: true