changeset 9755:0834c2591e14 3.2.x

Route MapServer through wiki container This reduces the need for local configuration changes to get a working Docker-based setup.
author Tom Gottfried <tom@intevation.de>
date Wed, 12 Oct 2022 12:53:36 +0200
parents cd07130ded8d
children a14836131b23
files artifacts/doc/conf/conf.xml docker/Dockerfile.mapserv docker/README docker/docker-compose.yml docker/httpd-wiki.conf gwt-client/src/main/java/org/dive4elements/river/client/server/MapPrintServiceImpl.java
diffstat 6 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/conf.xml	Wed Oct 12 10:45:13 2022 +0200
+++ b/artifacts/doc/conf/conf.xml	Wed Oct 12 12:53:36 2022 +0200
@@ -321,7 +321,8 @@
 
     <!-- MapServer integration -->
     <mapserver>
-        <server path="http://localhost:8081/cgi-bin/"/>
+        <!-- Can be absolute URL or just path if on the same host as client -->
+        <server path="/cgi-bin/"/>
         <!-- Directory where generated mapfiles and shapefiles will be stored -->
         <mapfiles path="${artifacts.config.dir}/../artifacts-data/mapserver/"/>
         <templates path="${artifacts.config.dir}/mapserver/"/>
--- a/docker/Dockerfile.mapserv	Wed Oct 12 10:45:13 2022 +0200
+++ b/docker/Dockerfile.mapserv	Wed Oct 12 12:53:36 2022 +0200
@@ -47,5 +47,4 @@
 # httpd config
 ADD httpd-mapserver.conf /etc/httpd/conf.d/
 
-EXPOSE 80
 CMD ["/usr/sbin/httpd", "-DFOREGROUND"]
--- a/docker/README	Wed Oct 12 10:45:13 2022 +0200
+++ b/docker/README	Wed Oct 12 12:53:36 2022 +0200
@@ -1,10 +1,8 @@
 Configure:
-_ Change 'localhost' to the hostname of your docker host in
-  artifacts/doc/conf/conf.xml
 _ Add to gwt-client/config/mapfish/config.yaml to enable map printing:
   - !dnsMatch
     host: <your-host>
-    port: 8081
+    port: 8080
 
 
 Build and run:
--- a/docker/docker-compose.yml	Wed Oct 12 10:45:13 2022 +0200
+++ b/docker/docker-compose.yml	Wed Oct 12 12:53:36 2022 +0200
@@ -36,8 +36,6 @@
       - ./mapserver/cgi-bin:/var/www/cgi-bin
       - ../artifacts/doc/conf/mapserver:/opt/d4e/bin/conf/mapserver
       - artifacts-data:/opt/d4e/bin/artifacts-data
-    ports:
-      - 8081:80
   client:
     container_name: "d4eriver-client"
     build:
--- a/docker/httpd-wiki.conf	Wed Oct 12 10:45:13 2022 +0200
+++ b/docker/httpd-wiki.conf	Wed Oct 12 12:53:36 2022 +0200
@@ -6,6 +6,10 @@
 ProxyPass "/d4e-river" "ajp://d4eriver-client:8009/d4e-river"
 ProxyPassReverse "/d4e-river" "ajp://d4eriver-client:8009/d4e-river"
 
+# MapServer
+ProxyPass "/cgi-bin" "http://d4eriver-mapserv/cgi-bin"
+ProxyPassReverse "/cgi-bin" "http://d4eriver-mapserv/cgi-bin"
+
 # Wiki
 WSGIScriptAlias /wiki /opt/wiki/moin-1.9.9/wiki/server/moin.wsgi
 WSGIDaemonProcess moin user=wiki group=wiki \
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/MapPrintServiceImpl.java	Wed Oct 12 10:45:13 2022 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/MapPrintServiceImpl.java	Wed Oct 12 12:53:36 2022 +0200
@@ -24,6 +24,8 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -76,7 +78,7 @@
         public Layer() {
         }
 
-        public boolean setup(Element element) {
+        public boolean setup(Element element, HttpServletRequest req) {
 
             Element parent = (Element)element.getParentNode();
             String parentName = parent.getAttribute("name");
@@ -94,7 +96,15 @@
                 return false;
             }
 
-            url         = element.getAttributeNS(ns, "url");
+            url = element.getAttributeNS(ns, "url");
+            try {
+                // if given URL is not absolute, complement it
+                url = new URL(new URL(req.getRequestURL().toString()),
+                    url).toString();
+            } catch (MalformedURLException mue) {
+                log.error("Failed to complement layer URL: "
+                    + mue.getMessage());
+            }
             layers      = element.getAttributeNS(ns, "layers");
             description = element.getAttributeNS(ns, "description");
 
@@ -134,6 +144,7 @@
     } // class Layer
 
     protected static String generateSpec(
+        HttpServletRequest req,
         Document descDocument,
         MapConfig mapConfig,
         Double minX, Double minY,
@@ -162,7 +173,7 @@
 
         for (int i = 0, N = facets.getLength(); i < N; ++i) {
             Element element = (Element)facets.item(i);
-            if (l.setup(element)) {
+            if (l.setup(element, req)) {
                 ls.add(l);
                 l = new Layer();
             }
@@ -378,6 +389,7 @@
         }
 
         String spec = generateSpec(
+            req,
             descDocument,
             mapConfig,
             minX, minY,

http://dive4elements.wald.intevation.org