[MapServer-users] Mapserver x k8s issue

Bjørn Ove Grøtan bjorn.ove at grotan.com
Fri Nov 25 10:03:25 PST 2022


Marcin Niemyjski via MapServer-users:
> Hello,
> 
> I'm involved in the development of a project connecting Mapserver with
> capabilities of Kubernetes like scalability, load balancing etc.
> 
> We've run into problem wich I think can be solved on the side o Mapserver,
> namely:
> 
> The k8s external IP cannot immediately be placed in "wms_onlineresource"
> because it takes time to generate it. Up to now I have checked the WMS
> operation by GetCapabilites, GetMap queries, and set "wms_onlineresource" to
> http://localhost:80/?map=/etc/mapserver/map1-test.map. I've made requests
> (GetMap GetCapabilites) via http://<External IP
> Address>/?map=/etc/mapserver/map1-test.map - everything was working. However,
> when loading the layer into QGIS nothing happened. I believe this is because
> even though the queries work using url with external IP, the information that
> comes in the XML file contains localhost:80 and QGIS is trying to connect to
> a layer that does not exist locally.
> 
> Is there any way for the mapserver to know that localhost:80 must be replaced
> with the external ip address from the query?

Comment out the ows_onlineresource configuration, and Mapserver will utilize whatever hostname you reached it at.
That way, the same mapfile can be used in local development, test/qa and production without need for changing
ows_onlineresource when moving between environments.

One caveat we came across, having a reverse proxy in front of our mapserver (w/apache).
http->http => wms_onlineresource will use http
https->https => wms_onlineresource will use https
https->http => wms_onlineresource will use http, even though http headers for forward port and forward proto is set.

Other than that, you will be fine with not configuring ows/wms_onlineresource in your mapfile.

-- 
Kind regards 
 
Bjørn Ove Grøtan



More information about the MapServer-users mailing list