<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi Paul,<br></div><div><br></div><div>The runtime substitution and setting a querystring on the server is a good approach - have you found any drawbacks to this? Most web servers can set/add querystrings without any need for further software. <br></div><div><br></div><div>As Steve mentioned the alternative would be to generate Mapfiles for specific environments from a template.<br></div><div>I use mappyfile for this, with a Python script that can be run as part of continuous deployment:<br></div><div><br></div><div>import mappyfile<br></div><div>mapfile = mappyfile.open("original.map")<br></div><div># update the web metadata settings<br></div><div>mapfile["web"]["metadata"]["ows_onlineresource"] = "<a href="https://example.com/cgi-bin/mapserv?map={}.map".format("test")">https://example.com/cgi-bin/mapserv?map={}.map".format("test")</a><br></div><div>mappyfile.save(mapfile, "new.map")<br></div><div></div><div><br></div><div>Typical other settings I'd change are connection strings, DEBUG level, and EXTENTs for different Mapfiles.<br></div><div><br></div><div>Seth<br></div><div><br></div><div id="sig62266145"><div class="signature">--<br></div><div class="signature">web:<a href="https://geographika.net">https://geographika.net</a><br></div><div class="signature">twitter: @geographika<br></div></div><div><br></div><div><br></div><div>On Wed, Apr 13, 2022, at 3:52 AM, Steve Lime wrote:<br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div>One other thing. One challenge with environment variables is knowing what's consistently available within a runtime environment - CGI is different from FastCGI and there are differences across web servers. That's one of the reasons pre-processing is kind of attractive IMHO. I suppose the v.8 config file could play a role but I'm unsure what that would be beyond a place to set values consistently.<br></div><div><br></div><div class="qt-gmail_quote"><div dir="ltr" class="qt-gmail_attr">On Tue, Apr 12, 2022 at 8:04 PM Steve Lime <<a href="mailto:sdlime@gmail.com">sdlime@gmail.com</a>> wrote:<br></div><blockquote class="qt-gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div dir="ltr"><div>Hi Paul: The idea of referencing environment variables has come up before. Another example would be to leverage settings injected into cloud deployments as environment variables (I think there's an old ticket that was recently re-opened on the topic). I'm not sure what the best way to handle this would be. One possibility would be using a mechanism similar to runtime subs where you'd reference the variables within the mapfile using ${variable} or whatever. Another idea would be to use a pre-processor of some sort to "compile" a mapfile from the environment. The latter would result in better performance since you'd generate the resulting file once and could also do things like inlining included snippets. This functionality would be helpful for the cloud deployments, simplifying deployments in multiple (dev, test, prod) environments and for keeping secrets out of repos altogether.<br></div><div><br></div><div>We're putzing around with the pre-processing idea a bit but haven't gotten anything fully baked. Others?<br></div><div><br></div><div>-Steve<br></div></div><div><br></div><div class="qt-gmail_quote"><div dir="ltr" class="qt-gmail_attr">On Tue, Apr 12, 2022 at 4:56 AM Paul via MapServer-users <<a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a>> wrote:<br></div><blockquote class="qt-gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div><div style="font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr">hi list, this has probably been discussed before, but maybe there are updates (on v8?)<br></div><div dir="ltr"><br></div><div dir="ltr">we would like to extract the <span><code>ows_onlineresource from the environment, instead of having an administrator to configure it on the mapfile</code></span><br></div><div dir="ltr"><br></div><div dir="ltr">currently we implement a hack where the webserver layer sends an additional query parameter `ows_url` to mapserver which contains the current url<br></div><div dir="ltr"><br></div><div dir="ltr">in the mapfile this is implemented as <br></div><div dir="ltr"><br></div><div dir="ltr">```<br></div><div dir="ltr"><div><pre lang="plaintext"><span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC1" lang="plaintext">WEB</span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC2" lang="plaintext">    VALIDATION</span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC3" lang="plaintext">      "ows_url" "(\b(https?|ftp|file)://)?[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"</span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC4" lang="plaintext">    END</span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC5" lang="plaintext">    </span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC6" lang="plaintext">    METADATA</span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC7" lang="plaintext">      "ows_onlineresource"               "%ows_url%"</span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC8" lang="plaintext">    END</span>
<span id="qt-gmail-m_8906421840414282941gmail-m_-1578593230117342386ydpa2a2adfLC9" lang="plaintext">END</span><br></pre></div></div><div dir="ltr">```<br></div><div dir="ltr"><br></div><div dir="ltr">I wonder if others run into similar challenges, or if there are much more simple best practices for this case.<br></div><div dir="ltr"><br></div><div dir="ltr">I can imagine allowing a environment parameter 'proxy-url' like geoserver would make sense, but it should allow some kind of template, eg:<br></div><div dir="ltr"><br></div><div dir="ltr">```<br></div><div dir="ltr">PROXY-URL <a href="https://example.com/cgi-bin/mapserv?map=%7Bmap%7D.map" target="_blank">https://example.com/cgi-bin/mapserv?map={map}.map</a><br></div><div dir="ltr">```<br></div><div dir="ltr"><br></div><div dir="ltr">which in our case would be <br></div><div dir="ltr"><br></div><div dir="ltr"><div><div dir="ltr" style="color:rgb(0, 0, 0);font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;">```<br></div><div dir="ltr" style="color:rgb(0, 0, 0);font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;">PROXY-URL <a href="https://example.com/cgi-bin/%7Bmap%7D" target="_blank">https://example.com/cgi-bin/{map}</a><br></div><div dir="ltr" style="color:rgb(0, 0, 0);font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;">```<br></div></div><div><br></div></div><div dir="ltr">Thank you, Paul.<br></div></div></div><div>_______________________________________________<br></div><div> MapServer-users mailing list<br></div><div> <a href="mailto:MapServer-users@lists.osgeo.org" target="_blank">MapServer-users@lists.osgeo.org</a><br></div><div> <a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div></blockquote></div></blockquote></div></div><div>_______________________________________________<br></div><div>MapServer-users mailing list<br></div><div><a href="mailto:MapServer-users@lists.osgeo.org">MapServer-users@lists.osgeo.org</a><br></div><div><a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div><div><br></div></blockquote><div><br></div></body></html>