Skip to content

Commit

Permalink
Enables support to turn on/off proxy protocol in config. (#9577)
Browse files Browse the repository at this point in the history
  • Loading branch information
spericas authored Dec 9, 2024
1 parent a69cc7f commit 4591886
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ interface ListenerConfigBlueprint {
*
* @return proxy support status
*/
@Option.Configured
@Option.Default("false")
boolean enableProxyProtocol();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
4 changes: 3 additions & 1 deletion webserver/webserver/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -57,6 +58,7 @@ server3:
sockets:
- name: "grace"
shutdown-grace-period: PT2S
enable-proxy-protocol: true

inject:
permits-dynamic: true

0 comments on commit 4591886

Please sign in to comment.