Skip to content

Instantly share code, notes, and snippets.

@arbakker
Created June 16, 2023 11:39
Show Gist options
  • Save arbakker/107c96b65519447a25e2092419d1868a to your computer and use it in GitHub Desktop.
Save arbakker/107c96b65519447a25e2092419d1868a to your computer and use it in GitHub Desktop.
PDOK MapServer docker-compose voorbeeld

PDOK MapServer docker-compose voorbeeld

MapServer docker-compose voorbeeld met lighttpd reverse-proxy, voor het toevoegen van response headers.

  1. Start docker-compose met:
docker-compose up
  1. Service draait nu op: http://localhost/mapserver?service=WMS&request=getcapabilities
version: "3.9"
services:
reverse-proxy:
tty: true
ports:
- "80:80"
image: sebp/lighttpd
environment:
LIGHTTPD_CONFIG: |-
server.modules = (
"mod_proxy",
"mod_setenv"
)
server.username = "lighttpd"
server.groupname = "lighttpd"
server.pid-file = "/run/lighttpd.pid"
server.document-root = "/var/www"
server.errorlog = "/dev/pts/0"
$$HTTP["host"] =~ "localhost" {
$$HTTP["url"] =~ "^/.*" {
proxy.server = ( "" =>
((
"host" => "wms",
"port" => 80,
))
)
}
}
setenv.add-response-header = (
"Access-Control-Allow-Origin" => "*",
"Access-Control-Allow-Headers" => "accept, origin, x-requested-with, content-type, x-transmission-session-id",
"Access-Control-Expose-Headers" => "X-Transmission-Session-Id",
"Access-Control-Allow-Methods" => "GET, POST, OPTIONS"
)
depends_on:
- wms
command: >
/bin/ash -cx "echo $${LIGHTTPD_CONFIG} > /etc/lighttpd/lighttpd.conf && /usr/local/bin/start.sh"
wms:
tty: true
image: pdok/mapserver:7.6.4-patch-5-5 # issue DOES NOT occur with this image (does not contain rdnaptrans)
environment:
MS_MAPFILE: /srv/service.map
SERVICE_TYPE: WMS
command: >
/bin/bash -cx "lighttpd -D -f /srv/mapserver/config/lighttpd.conf"
volumes:
- ${PWD}/service.map:/srv/service.map
- ${PWD}/polygons.json:/srv/data/polygons.json
- ${PWD}/example.html:/srv/data/example.html
<!-- MapServer Template -->
<html>
<head>
<title>GetFeatureInfo output</title>
</head>
<style type="text/css">
table.featureInfo,
table.featureInfo td,
table.featureInfo th {
border: 1px solid #ddd;
border-collapse: collapse;
margin: 0;
padding: 0;
font-size: 90%;
padding: .2em .1em;
}
table.featureInfo th {
padding: .2em .2em;
font-weight: bold;
background: #eee;
}
table.featureInfo td {
background: #fff;
}
table.featureInfo tr.odd td {
background: #eee;
}
table.featureInfo caption {
text-align: left;
font-size: 100%;
font-weight: bold;
padding: .2em .2em;
}
</style>
<body>
<table class="featureInfo">
<caption class="featureInfo">polygons</caption>
<tr>
<th>fid</th>
<th>name</th>
</tr>
<tr>
<td>[fid]</td>
<td>[name]</td>
</tr>
</table>
<br />
</body>
</html>
server.modules += ( "mod_setenv" )
server.modules += ( "mod_fastcgi" )
server.modules += ( "mod_rewrite" )
server.modules += ( "mod_magnet" )
server.document-root = "/var/www/"
server.port = 80
server.tag = ""
server.http-parseopts = ( "url-ctrls-reject" => "disable")
server.username = "www"
server.groupname = "www"
server.errorlog = "/dev/stderr"
fastcgi.debug = env.DEBUG
magnet.attract-raw-url-to += ("/srv/mapserver/config/request.lua")
include "include.conf"
fastcgi.server = (
"/mapserver" => (
"mapserver" => (
"socket" => "/tmp/mapserver-fastcgi.socket",
"check-local" => "disable",
"bin-path" => "/usr/local/bin/mapserv",
"min-procs" => env.MIN_PROCS,
"max-procs" => env.MAX_PROCS,
"max-load-per-proc" => env.MAX_LOAD_PER_PROC,
"idle-timeout" => env.IDLE_TIMEOUT
)
)
)
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
MAP
NAME ""
CONFIG "MS_ERRORFILE" "stderr"
EXTENT 2 50 9 54
UNITS meters
STATUS ON
SIZE 5000 5000
## global debug settings for mapserver, remove comment in lines below to enable
# DEBUG 4 # https://mapserver.org/optimization/debugging.html
# CONFIG "CPL_DEBUG" "ON" # GDAL
RESOLUTION 91
DEFRESOLUTION 91
PROJECTION
"init=epsg:4326"
END
WEB
METADATA
"ows_enable_request" "*"
"ows_fees" "NONE"
"ows_contactorganization" "Unknown"
"ows_schemas_location" "http://schemas.opengis.net"
"ows_service_onlineresource" "http://localhost"
"ows_contactperson" "ContactCenter Unknown"
"ows_contactposition" "pointOfContact"
"ows_contactvoicetelephone" ""
"ows_contactfacsimiletelephone" ""
"ows_addresstype" ""
"ows_address" ""
"ows_city" "City"
"ows_stateorprovince" ""
"ows_postcode" ""
"ows_country" "Country"
"ows_contactelectronicmailaddress" "example@unknown.org"
"ows_hoursofservice" ""
"ows_contactinstructions" ""
"ows_role" ""
"ows_srs" "EPSG:4326 EPSG:3857 EPSG:4258 CRS:84"
"ows_accessconstraints" "otherRestrictions;http://creativecommons.org/publicdomain/mark/1.0"
END
END
# outputformat used by WMS GetFeatureInfo and the WFS GetFeature requests
OUTPUTFORMAT
NAME "GEOJSON" # format name (visible as format in the 1.0.0 capabilities)
DRIVER "OGR/GEOJSON"
MIMETYPE "application/json; subtype=geojson"
FORMATOPTION "STORAGE=stream"
FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "USE_FEATUREID=true"
FORMATOPTION "LCO:ID_FIELD=fid"
FORMATOPTION "LCO:ID_TYPE=STRING"
END
# outputformat used by WMS GetFeatureInfo and the WFS GetFeature requests
OUTPUTFORMAT
NAME "JSON"
DRIVER "OGR/GEOJSON"
MIMETYPE "application/json"
FORMATOPTION "STORAGE=stream"
FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "USE_FEATUREID=true"
FORMATOPTION "LCO:ID_FIELD=fid"
FORMATOPTION "LCO:ID_TYPE=STRING"
END
# outputformat used by WMS GetFeatureInfo request, not the WFS GetFeature requests
OUTPUTFORMAT
NAME "XML"
DRIVER "OGR/GML"
MIMETYPE "text/xml"
FORMATOPTION "STORAGE=stream"
FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "USE_FEATUREID=true"
FORMATOPTION "DSCO:GML_ID=fid"
FORMATOPTION "DSCO:PREFIX=example"
FORMATOPTION "DSCO:XSISCHEMAURI=http://example.unknown.org"
END
# outputformat used by WMS GetFeatureInfo request, not the WFS GetFeature requests
OUTPUTFORMAT
NAME "OGRGML3"
DRIVER "OGR/GML"
MIMETYPE "text/xml; subtype=gml/3.1.1"
FORMATOPTION "STORAGE=stream"
FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "USE_FEATUREID=true"
FORMATOPTION "DSCO:FORMAT=GML3Deegree"
FORMATOPTION "DSCO:GML_FEATURE_COLLECTION=YES"
FORMATOPTION "DSCO:PREFIX=example"
FORMATOPTION "DSCO:XSISCHEMA=EXTERNAL"
FORMATOPTION "DSCO:TARGET_NAMESPACE=http://example.unknown.org"
FORMATOPTION "DSCO:XSISCHEMAURI=http://example.unknown.org http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"
END
# outputformat used by WMS GetFeatureInfo requests, not the WFS GetFeature requests
OUTPUTFORMAT
NAME "OGRGML32"
DRIVER "OGR/GML"
MIMETYPE "text/xml; subtype=gml/3.2.1"
FORMATOPTION "STORAGE=stream"
FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "USE_FEATUREID=true"
FORMATOPTION "DSCO:FORMAT=GML3.2"
FORMATOPTION "DSCO:GML_ID=wms.example.getfeatureinfo.collection"
FORMATOPTION "DSCO:GML_FEATURE_COLLECTION=YES"
FORMATOPTION "DSCO:PREFIX=example"
FORMATOPTION "DSCO:XSISCHEMA=EXTERNAL"
FORMATOPTION "DSCO:TARGET_NAMESPACE=http://example.unknown.org"
FORMATOPTION "DSCO:XSISCHEMAURI=http://example.unknown.org http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd"
END
# outputformat used by WMS GetMap requests
OUTPUTFORMAT
NAME "SVG"
DRIVER CAIRO/SVG
MIMETYPE "image/svg+xml"
IMAGEMODE RGB
EXTENSION "svg"
END
# outputformat used by tiled requests
OUTPUTFORMAT
NAME "mvt"
DRIVER MVT
FORMATOPTION "EDGE_BUFFER=20"
EXTENSION "pbf"
FORMATOPTION "EXTENT=4096"
END
WEB
METADATA
"ows_title" "Example"
"ows_abstract" "Service containing a example"
"ows_keywordlist" "example,unknown"
"ows_schemas_location" "http://schemas.opengis.net"
"wfs_extent" "2 50 9 54"
"wfs_namespace_prefix" "example"
"wfs_namespace_uri" "http://example.unknown.org"
"wfs_maxfeatures" "1000"
"wfs_onlineresource" "http://localhost"
"wms_getmap_formatlist" "image/png,image/jpeg,image/png; mode=8bit,image/vnd.jpeg-png,image/vnd.jpeg-png8,image/svg+xml"
"wms_enable_request" "* !GetStyles !DescribeLayer"
"wms_bbox_extended" "true"
"wms_namespace_prefix" "example"
"wms_namespace_uri" "http://example.unknown.org"
"wms_getfeatureinfo_formatlist" "text/html,text/xml; subtype=gml/3.2.1,text/xml; subtype=gml/3.1.1,application/json,application/json; subtype=geojson"
"ows_sld_enabled" "false"
END
END
LAYER
NAME "example"
STATUS ON
TYPE POLYGON
## layer debug settings for mapserver, remove comment in lines below to enable
# DEBUG 4
METADATA
"wfs_title" "example"
"wfs_abstract" "Layer containing the example data"
"wfs_srs" "EPSG:4326 EPSG:3857 EPSG:4258 CRS:84"
"wfs_extent" "2 50 9 54"
"wfs_bbox_extended" "true"
"wfs_enable_request" "*"
"wfs_include_items" "all"
"wfs_getfeature_formatlist" "OGRGML3,OGRGML32,GEOJSON,JSON"
"gml_include_items" "all"
"gml_exclude_items" "id"
"gml_featureid" "id"
"gml_geometries" "geom"
"gml_types" "auto"
"wms_title" "example"
"wms_extent" "2 50 9 54"
"wms_abstract" "Layer containing the example data"
"wms_srs" "EPSG:4326 EPSG:3857 EPSG:4258 CRS:84"
"wms_keywordlist" "example,unknown"
"wms_include_items" "all"
END
CLASSGROUP "example:style"
CLASS
NAME "example"
GROUP "example:style"
STYLE
COLOR 230 230 0
OUTLINECOLOR 255 0 0
WIDTH 1
END
END
PROJECTION
"init=epsg:4326"
END
CONNECTIONTYPE OGR
CONNECTION "/srv/data/polygons.json"
DATA "polygons"
TEMPLATE /srv/data/example.html
END # LAYER
END # MAP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment