summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src
diff options
context:
space:
mode:
authorManuel Bentele2021-06-28 09:26:17 +0200
committerManuel Bentele2021-06-28 09:26:17 +0200
commitc4f1dbb6071808d8c20c1149b249d9d526b56d46 (patch)
tree780068a74c985ecbe73e437615f66fbc0f75ee1e /dozentenmodulserver/src
parent[server] Add URL path /bwlp/container/clusterimages to retrieve information a... (diff)
downloadtutor-module-c4f1dbb6071808d8c20c1149b249d9d526b56d46.tar.gz
tutor-module-c4f1dbb6071808d8c20c1149b249d9d526b56d46.tar.xz
tutor-module-c4f1dbb6071808d8c20c1149b249d9d526b56d46.zip
[server] Make webserver listen on every address in Docker setup
Diffstat (limited to 'dozentenmodulserver/src')
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java20
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebServer.java3
2 files changed, 22 insertions, 1 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java
index 8b6caf3d..58134cfc 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java
@@ -20,6 +20,8 @@ public class Configuration {
private static final Logger LOGGER = Logger.getLogger(Configuration.class);
private static final DateTimeFormatter subdirDate = DateTimeFormat.forPattern("yy-MM");
+ private static final String DEFAULT_WEBSERVER_BIND_ADDRESS_LOCAL = "127.0.0.1";
+
private static File vmStoreBasePath;
private static File vmStoreProdPath;
private static String dbUri;
@@ -28,6 +30,7 @@ public class Configuration {
private static String masterAddress;
private static boolean masterSsl = true;
private static int masterPort = 9091;
+ private static boolean webServerBindLocalhost = true;
private static String dbLocationTable;
private static SSLContext ctx = null;
@@ -56,6 +59,10 @@ public class Configuration {
} catch (Exception e) {
}
+ if (!Util.isEmptyString(prop.getProperty("webserver.bindLocalhost"))) {
+ webServerBindLocalhost = Boolean.parseBoolean(prop.getProperty("webserver.bindLocalhost"));
+ }
+
// Currently all fields are mandatory but there might be optional settings in the future
return vmStoreBasePath != null && dbUri != null && dbUsername != null && dbPassword != null;
}
@@ -104,6 +111,19 @@ public class Configuration {
return masterPort;
}
+ public static boolean getWebServerBindLocalhost() {
+ return webServerBindLocalhost;
+ }
+
+ public static String getWebServerBindAddressLocal() {
+ if (getWebServerBindLocalhost()) {
+ return DEFAULT_WEBSERVER_BIND_ADDRESS_LOCAL;
+ } else {
+ // do not bind to the localhost address
+ return null;
+ }
+ }
+
// Dynamically Computed fields
public static File getCurrentVmStorePath() {
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebServer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebServer.java
index 9840a4c2..a3d9d293 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebServer.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebServer.java
@@ -25,6 +25,7 @@ import org.openslx.bwlp.sat.database.mappers.DbLecture;
import org.openslx.bwlp.sat.database.mappers.DbLecture.LaunchData;
import org.openslx.bwlp.sat.database.mappers.DbLecture.RunScript;
import org.openslx.bwlp.sat.fileserv.FileServer;
+import org.openslx.bwlp.sat.util.Configuration;
import org.openslx.bwlp.thrift.iface.NetRule;
import org.openslx.bwlp.thrift.iface.NetShare;
import org.openslx.bwlp.thrift.iface.NetShareAuth;
@@ -47,7 +48,7 @@ public class WebServer extends NanoHTTPD {
private static final Serializer serializer = new Persister();
public WebServer(int port) {
- super("127.0.0.1", port);
+ super(Configuration.getWebServerBindAddressLocal(), port);
super.maxRequestSize = 65535;
}