diff --git a/src/main/java/eu/openaire/pdf_aggregation_statistics/util/UriBuilder.java b/src/main/java/eu/openaire/pdf_aggregation_statistics/util/UriBuilder.java index fd7bb17..3cdd698 100644 --- a/src/main/java/eu/openaire/pdf_aggregation_statistics/util/UriBuilder.java +++ b/src/main/java/eu/openaire/pdf_aggregation_statistics/util/UriBuilder.java @@ -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(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 681353b..d169130 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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