Skip to content

Commit 4591886

Browse files
authored
Enables support to turn on/off proxy protocol in config. (helidon-io#9577)
1 parent a69cc7f commit 4591886

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

webserver/webserver/src/main/java/io/helidon/webserver/ListenerConfigBlueprint.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ interface ListenerConfigBlueprint {
366366
*
367367
* @return proxy support status
368368
*/
369+
@Option.Configured
369370
@Option.Default("false")
370371
boolean enableProxyProtocol();
371372

webserver/webserver/src/test/java/io/helidon/webserver/ListenerConfigTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,24 @@ void testSpecificListenerConfigFromConfigFile() {
5757
assertThat(listenerConfig.shutdownGracePeriod().toMillis(), is(2000L));
5858
}
5959

60+
@Test
61+
void testEnableProxyProtocolConfig() {
62+
Config config = Config.create();
63+
64+
// default is false in default socket
65+
var webServerConfig = WebServer.builder().config(config.get("server")).buildPrototype();
66+
assertThat(webServerConfig.enableProxyProtocol(), is(false));
67+
ListenerConfig otherConfig = webServerConfig.sockets().get("other");
68+
assertThat(otherConfig.enableProxyProtocol(), is(false));
69+
70+
// set to true in default socket
71+
var webServerConfig2 = WebServer.builder().config(config.get("server2")).buildPrototype();
72+
assertThat(webServerConfig2.enableProxyProtocol(), is(true));
73+
74+
// set to true in non-default socket
75+
var webServerConfig3 = WebServer.builder().config(config.get("server3")).buildPrototype();
76+
assertThat(webServerConfig3.enableProxyProtocol(), is(false));
77+
ListenerConfig graceConfig = webServerConfig3.sockets().get("grace");
78+
assertThat(graceConfig.enableProxyProtocol(), is(true));
79+
}
6080
}

webserver/webserver/src/test/resources/application.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
# Copyright (c) 2022, 2024 Oracle and/or its affiliates.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@ server2:
4545
port: 8079
4646
host: 127.0.0.1
4747
shutdown-grace-period: PT1S
48+
enable-proxy-protocol: true
4849

4950
connection-providers-discover-services: false
5051
media-context:
@@ -57,6 +58,7 @@ server3:
5758
sockets:
5859
- name: "grace"
5960
shutdown-grace-period: PT2S
61+
enable-proxy-protocol: true
6062

6163
inject:
6264
permits-dynamic: true

0 commit comments

Comments
 (0)