100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Make manager backend web server path configurable (#1670)
Wouter Born5d4396746a1c
diff --git a/manager/src/main/java/org/openremote/manager/map/MapService.java b/manager/src/main/java/org/openremote/manager/map/MapService.javaindex 9e2f0cad5..e2f10d0ba 100644--- a/manager/src/main/java/org/openremote/manager/map/MapService.java+++ b/manager/src/main/java/org/openremote/manager/map/MapService.java@@ -63,14 +63,18 @@ public class MapService implements ContainerService {public static final String TILESERVER_TILE_PATH = "/styles/standard";public static final String OR_MAP_TILESERVER_REQUEST_TIMEOUT = "OR_MAP_TILESERVER_REQUEST_TIMEOUT";public static final int OR_MAP_TILESERVER_REQUEST_TIMEOUT_DEFAULT = 10000;+ public static final String OR_PATH_PREFIX = "OR_PATH_PREFIX";+ public static final String OR_PATH_PREFIX_DEFAULT = "";private static final Logger LOG = Logger.getLogger(MapService.class.getName());private static ConfigurationService configurationService;+// Shared SQL connection is fine concurrently in SQLiteprotected Connection connection;protected Metadata metadata;protected ObjectNode mapConfig;protected ConcurrentMap<String, ObjectNode> mapSettings = new ConcurrentHashMap<>();protected ConcurrentMap<String, ObjectNode> mapSettingsJs = new ConcurrentHashMap<>();+ protected String pathPrefix;public ObjectNode saveMapConfig(Map<String, MapRealmConfig> mapConfiguration) throws RuntimeException {if (mapConfig == null) {@@ -146,6 +150,7 @@ public class MapService implements ContainerService {String tileServerHost = getString(container.getConfig(), OR_MAP_TILESERVER_HOST, OR_MAP_TILESERVER_HOST_DEFAULT);int tileServerPort = getInteger(container.getConfig(), OR_MAP_TILESERVER_PORT, OR_MAP_TILESERVER_PORT_DEFAULT);+ pathPrefix = getString(container.getConfig(), OR_PATH_PREFIX, OR_PATH_PREFIX_DEFAULT);if (!TextUtil.isNullOrEmpty(tileServerHost)) {@@ -286,7 +291,7 @@ public class MapService implements ContainerService {}));ArrayNode tilesArray = mapConfig.arrayNode();- String tileUrl = UriBuilder.fromUri(host).replacePath(API_PATH).path(realm).path("map/tile").build().toString() + "/{z}/{x}/{y}";+ String tileUrl = UriBuilder.fromUri(host).replacePath(pathPrefix + API_PATH).path(realm).path("map/tile").build().toString() + "/{z}/{x}/{y}";tilesArray.insert(0, tileUrl);vectorTilesObj.replace("tiles", tilesArray);});@@ -295,7 +300,7 @@ public class MapService implements ContainerService {Optional.ofNullable(settings.has("sprite") && settings.get("sprite").isTextual() ? settings.get("sprite").asText() : null).ifPresent(sprite -> {String spriteUri =UriBuilder.fromUri(host)- .replacePath(MAP_SHARED_DATA_BASE_URI)+ .replacePath(pathPrefix + MAP_SHARED_DATA_BASE_URI).path(sprite).build().toString();settings.put("sprite", spriteUri);@@ -305,7 +310,7 @@ public class MapService implements ContainerService {Optional.ofNullable(settings.has("glyphs") && settings.get("glyphs").isTextual() ? settings.get("glyphs").asText() : null).ifPresent(glyphs -> {String glyphsUri =UriBuilder.fromUri(host)- .replacePath(MAP_SHARED_DATA_BASE_URI)+ .replacePath(pathPrefix + MAP_SHARED_DATA_BASE_URI).build().toString() + "/fonts/" + glyphs;settings.put("glyphs", glyphsUri);});diff --git a/profile/deploy.yml b/profile/deploy.ymlindex 564ddd46a..d37fbb2ba 100644--- a/profile/deploy.yml+++ b/profile/deploy.yml@@ -102,6 +102,10 @@ services:PROXY_HOST_REDIRECT_10_NAME:PROXY_HOST_REDIRECT_10_TARGET:+ # The proxy removes path prefixes when configured before sending the request to the manager or keycloak.+ #MANAGER_PATH_PREFIX: /openremote+ #KEYCLOAK_PATH_PREFIX: /keycloak+# Expose public services (web server, MQTT broker)ports:- "80:80" # HTTP for letsencrypt cert generation and in general it redirects to 443 for HTTPS@@ -348,6 +352,9 @@ services:# API key for the API of ForecastSolar: https://forecast.solar# OR_FORECAST_SOLAR_API_KEY+ # When using path based proxying this prefix is added to the URLs returned via the REST API.+ # OR_PATH_PREFIX: /openremote+# Custom JVM options (override default manager options)#OR_JAVA_OPTS: ${OR_JAVA_OPTS:--Xms500m -Xmx2g# -XX:NativeMemoryTracking=summarydiff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.tsindex 7b0540419..9b5f46397 100644--- a/ui/component/core/src/index.ts+++ b/ui/component/core/src/index.ts@@ -91,12 +91,17 @@ export function normaliseConfig(config: ManagerConfig): ManagerConfig {if (!normalisedConfig.managerUrl || normalisedConfig.managerUrl === "") {// Assume manager is running on same host as this code- normalisedConfig.managerUrl = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");+ normalisedConfig.managerUrl = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "")+ + window.location.pathname.replace(/\/manager\/\S*/g, "");} else {// Normalise by stripping any trailing slashesnormalisedConfig.managerUrl = normalisedConfig.managerUrl.replace(/\/+$/, "");}+ if (!normalisedConfig.keycloakUrl || normalisedConfig.keycloakUrl === "") {+ normalisedConfig.keycloakUrl = normalisedConfig.managerUrl + "/auth";+ }+if (!normalisedConfig.realm || normalisedConfig.realm === "") {// Assume master realmnormalisedConfig.realm = "master";