[PATCH 2 of 2] Route MapServer through wiki container

Wald Commits scm-commit at wald.intevation.org
Wed Oct 12 12:54:48 CEST 2022


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1665572016 -7200
#      Wed Oct 12 12:53:36 2022 +0200
# Branch 3.2.x
# Node ID 0834c2591e14def5b05ab835d233613e352745c1
# Parent  cd07130ded8dba109713823ce6732481da2654c6
Route MapServer through wiki container

This reduces the need for local configuration changes to get
a working Docker-based setup.

diff -r cd07130ded8d -r 0834c2591e14 artifacts/doc/conf/conf.xml
--- 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/"/>
diff -r cd07130ded8d -r 0834c2591e14 docker/Dockerfile.mapserv
--- 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"]
diff -r cd07130ded8d -r 0834c2591e14 docker/README
--- 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:
diff -r cd07130ded8d -r 0834c2591e14 docker/docker-compose.yml
--- 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:
diff -r cd07130ded8d -r 0834c2591e14 docker/httpd-wiki.conf
--- 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 \
diff -r cd07130ded8d -r 0834c2591e14 gwt-client/src/main/java/org/dive4elements/river/client/server/MapPrintServiceImpl.java
--- 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,


More information about the Dive4Elements-commits mailing list