From 8cca40fd73e1120654e474d02e9230e66bc96025 Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Mon, 3 Feb 2020 12:02:20 -0600
Subject: [PATCH] Add basic working MapCache set of files

Assumes exiting SQLite database
---
 mapserver/Dockerfile |  4 ++++
 mapserver/site-conf  | 11 ++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/mapserver/Dockerfile b/mapserver/Dockerfile
index 4982922..75d218c 100644
--- a/mapserver/Dockerfile
+++ b/mapserver/Dockerfile
@@ -54,6 +54,7 @@ COPY cgi-bin/* /usr/lib/cgi-bin/
 
 # Point apache to the mapserver binary
 RUN ln -s /usr/local/bin/mapserv /usr/lib/cgi-bin/mapserv && \
+    ln -s /usr/local/bin/mapserv /usr/lib/cgi-bin/mapserv.fcgi && \
     chown ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/* && \
     chown -h ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/*
 
@@ -66,6 +67,9 @@ COPY html/ /var/www/html/
 COPY sql/ /work/sql/
 RUN sqlite3 -init /work/sql/goesr_crs.sql /usr/local/share/proj/proj.db
 
+# Check the config before we finish
+RUN apache2ctl configtest
+
 # https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
 STOPSIGNAL WINCH
 
diff --git a/mapserver/site-conf b/mapserver/site-conf
index 0c812d2..b83c316 100644
--- a/mapserver/site-conf
+++ b/mapserver/site-conf
@@ -28,16 +28,25 @@
         #Include conf-available/serve-cgi-bin.conf
 
         # Custom CSPP Geo
-        # LoadModule rewrite_module modules/mod_rewrite.so
         RewriteEngine on
         # /wms/goes16/abi/fldk/
         RewriteRule   "^/wms/([^/]+)/([^/]+)/([^/]+)/l1b?(.*)" "/cgi-bin/mapserv?map=/work/mapfiles/$1_$2_$3_l1b.map&$4" [PT,QSA]
+        # FCGI version of the above
+        RewriteRule   "^/fwms/([^/]+)/([^/]+)/([^/]+)/l1b?(.*)" "/cgi-bin/mapserv.fcgi?map=/work/mapfiles/$1_$2_$3_l1b.map&$4" [PT,QSA]
         # /wms_times/g16/abi/radf/true_color
         RewriteRule   "^/wms_times/([^/]+)/([^/]+)/([^/]+)/([^/]+)" "/cgi-bin/layer_times.py?layer=/data/tiles/$1/$2/$3/$4/$4.shp" [PT,QSA]
         # FIXME: We need to include the sector
         # /data/goes/grb/goes16/2020/2020_01_21_021/abi/L1b/RadF/GOES-16_ABI_RadF_C01_20200121_000016_GOES-East.tif
         # "/data/tiles/g16/abi/radf/true_color/true_color"
         LogLevel alert rewrite:trace6
+
+        # handler should be added by the enabled module
+        #AddHandler fcgid-script fcgi
+        <IfModule mod_fcgid.c>
+           FcgidMaxProcessesPerClass 30
+           FcgidInitialEnv PROJ_LIB /usr/local/share/proj
+           FcgidInitialEnv LD_LIBRARY_PATH "/usr/local/lib:/usr/local/pgsql/lib:/usr3/pkg3/oracle9/lib"
+        </IfModule>
 </VirtualHost>
 
 # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
\ No newline at end of file
-- 
GitLab