Allow to set an "root_address" in application.yml. This is used to declare the address of this server, when using proxy.

This commit is contained in:
Lampros Smyrnaios 2023-11-09 16:40:35 +02:00
parent 2e00ddba1b
commit 2656fc0b72
2 changed files with 6 additions and 1 deletions

View File

@ -31,7 +31,10 @@ public class UriBuilder {
baseUrl += sslEnabled.equals("true") ? "s" : "";
baseUrl += "://";
if ( (ip = getPublicIP()) == null )
String defined_address = environment.getProperty("server.root_address");
if ( (defined_address != null) && !defined_address.isEmpty() )
ip = defined_address;
else if ( (ip = getPublicIP()) == null )
ip = InetAddress.getLoopbackAddress().getHostAddress(); // Non-null.
baseUrl += ip + ":" + webServerAppCtxt.getWebServer().getPort();

View File

@ -1,5 +1,7 @@
server:
port: 1882
# Just a custom address to be shown to the logs and allow for easier testing, when using proxy. This is not the setting to bind the server to this address.
root_address:
servlet:
context-path: /api
shutdown: graceful