Re: Dynamic wfs_onlineresource

Matthias Müller <[email protected]> Thu, 17 Oct 2019 13:37:45 +0200
Newsgroups gmane.comp.gis.mapserver.user
Message-ID <[email protected]>
--===============6578236502292348440==
Content-Type: multipart/alternative; boundary="=-gtYWbIIKDr5EFpSYoGC/"


--=-gtYWbIIKDr5EFpSYoGC/
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit

Yves,

thanks for the hint - it works, but produces an ugly URL that exposes
the FS-Link of the mapfile to the public:

<ows:Get xlink:type="simple" xlink:href="
https://server1.org/mapserver/?map=/opt/service/mapserver/mapfile.map&"/
>

I should have mentioned that a reverse proxy runs in front of
Mapserver, that adds the mapfile to the request:

  location /mapserver {
    # Add header for CORS requests
    add_header Access-Control-Allow-Origin *;

    # Load from /etc/init.d/mapserv
    fastcgi_pass 127.0.0.1:9999;

    # Rewrite url to hide mapfile path
    rewrite ^(/mapserver.*)?(.*)$
$1?map=/opt/service/mapserver/mapfile.map$2 break;

    include fastcgi_params;
    fastcgi_param SCRIPT_NAME /usr/bin/mapserv$fastcgi_script_name;
  }

Is there another solution that works in conjunction with my reverse
proxy? Many other server products respect proxy headers and substitute
the filds of the private internal URL scheme with the corresponding
elements of the public URL of the caller.


- Matthias

Am Donnerstag, den 17.10.2019, 11:37 +0200 schrieb Yves Jacolin:
> Matthias,
> 
> Just remove the parameter will imply that MapServer will find the
> correct online resource.
> 
> Y.
> 
> Le jeu. 17 oct. 2019 à 11:35, Matthias Müller <
> [email protected]> a écrit :
> > Hi,
> > 
> > we are running WFS services with similar mapfiles on different
> > servers.
> > 
> > Setting the "wfs_onlineresource" is straight forward, but requires
> > a
> > hard coded host name:
> > 
> > First server:
> >   WEB
> >     METADATA
> >       "wfs_title"          "myserver"
> >       "wfs_onlineresource" "https://server1.org/mapserver?"
> >       "wfs_srs"            "EPSG:4326"
> >       "wfs_enable_request" "*"  # necessary
> >     END
> >   END
> > 
> > 
> > Second server:
> >   WEB
> >     METADATA
> >       "wfs_title"          "myserver"
> >       "wfs_onlineresource" "https://server2.org/mapserver?"
> >       "wfs_srs"            "EPSG:4326"
> >       "wfs_enable_request" "*"  # necessary
> >     END
> >   END
> > 
> > 
> > I there way to let mapserver figure out the hostname from the
> > request
> > and create the appropiate links in the WFS capabilities
> > accordingly?
> > 
> > Something like:
> > 
> >   WEB
> >     METADATA
> >       "wfs_title"          "myserver"
> >       "wfs_online
> > resource" "{request protocol and hostname}/mapserver?"
> >       "wfs_srs"  
> >           "EPSG:4326"
> >       "wfs_enable_request" "*"  # necessary
> >     END
> >   END
> > 
> > 
> > -Matthias
> > 
> > _______________________________________________
> > mapserver-users mailing list
> > [email protected]
> > https://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

--=-gtYWbIIKDr5EFpSYoGC/
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html dir=3D"ltr"><head></head><body style=3D"text-align:left; direction:lt=
r;"><div>Yves,</div><div><br></div><div>thanks for the hint - it works, but=
 produces an ugly URL that exposes the FS-Link of the mapfile to the public=
:</div><div><br></div><div>&lt;ows:Get xlink:type=3D"simple" xlink:href=3D"=
<a href=3D"https://baumkataster-test.pikobytes.de/mapserver/?map=3D/opt/pik=
obytes/mapserver/mapfile.map&amp;" "=3D"">https://server1.org/mapserver/?ma=
p=3D/opt/service/mapserver/mapfile.map&amp;"/</a>&gt;</div><div><br></div><=
div>I should have mentioned that a reverse proxy runs in front of Mapserver=
, that adds the mapfile to the request:</div><div><br></div><div>&nbsp; loc=
ation /mapserver {</div><div>&nbsp;&nbsp;&nbsp;&nbsp;# Add header for CORS =
requests</div><div>&nbsp;&nbsp;&nbsp;&nbsp;add_header Access-Control-Allow-=
Origin *;</div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;# Load from /etc=
/init.d/mapserv</div><div>&nbsp;&nbsp;&nbsp;&nbsp;fastcgi_pass 127.0.0.1:99=
99;</div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;# Rewrite url to hide =
mapfile path</div><div>&nbsp;&nbsp;&nbsp;&nbsp;rewrite ^(/mapserver.*)?(.*)=
$ $1?map=3D/opt/service/mapserver/mapfile.map$2 break;</div><div><br></div>=
<div>&nbsp;&nbsp;&nbsp;&nbsp;include fastcgi_params;</div><div>&nbsp;&nbsp;=
&nbsp;&nbsp;fastcgi_param SCRIPT_NAME /usr/bin/mapserv$fastcgi_script_name;=
</div><div>&nbsp; }</div><div><br></div><div>Is there another solution that=
 works in conjunction with my reverse proxy? Many other server products res=
pect proxy headers and substitute the filds of the private internal URL sch=
eme with the corresponding elements of the public URL of the caller.</div><=
div><br></div><div><br></div><div>- Matthias</div><div><br></div><div>Am Do=
nnerstag, den 17.10.2019, 11:37 +0200 schrieb Yves Jacolin:</div><blockquot=
e type=3D"cite" style=3D"margin:0 0 0 .8ex; border-left:2px #729fcf solid;p=
adding-left:1ex"><div>Matthias,</div><div><br></div><div>Just remove the pa=
rameter will imply that MapServer will find the correct online resource.</d=
iv><div><br></div><div>Y.</div><div><br></div><div>Le&nbsp;jeu. 17 oct. 201=
9 =C3=A0&nbsp;11:35, Matthias M=C3=BCller &lt;<a href=3D"mailto:matthias_mu=
[email protected]">[email protected]</a>&gt; a =C3=A9crit&nb=
sp;:</div><blockquote type=3D"cite" style=3D"margin:0 0 0 .8ex; border-left=
:2px #729fcf solid;padding-left:1ex"><div>Hi,</div><div><br></div><div>we a=
re running WFS services with similar mapfiles on different servers.</div><d=
iv><br></div><div>Setting the "wfs_onlineresource" is straight forward, but=
 requires a</div><div>hard coded host name:</div><div><br></div><div>First =
server:</div><div>&nbsp; WEB</div><div>&nbsp; &nbsp; METADATA</div><div>&nb=
sp; &nbsp; &nbsp; "wfs_title"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "myserver"<=
/div><div>&nbsp; &nbsp; &nbsp; "wfs_onlineresource" "<a href=3D"https://ser=
ver1.org/mapserver">https://server1.org/mapserver</a>?"</div><div>&nbsp; &n=
bsp; &nbsp; "wfs_srs"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "EPSG:4326"<=
/div><div>&nbsp; &nbsp; &nbsp; "wfs_enable_request" "*"&nbsp; # necessary</=
div><div>&nbsp; &nbsp; END</div><div>&nbsp; END</div><div><br></div><div><b=
r></div><div>Second server:</div><div>&nbsp; WEB</div><div>&nbsp; &nbsp; ME=
TADATA</div><div>&nbsp; &nbsp; &nbsp; "wfs_title"&nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; "myserver"</div><div>&nbsp; &nbsp; &nbsp; "wfs_onlineresource" "<a=
 href=3D"https://server2.org/mapserver">https://server2.org/mapserver</a>?"=
</div><div>&nbsp; &nbsp; &nbsp; "wfs_srs"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; "EPSG:4326"</div><div>&nbsp; &nbsp; &nbsp; "wfs_enable_request" "*"=
&nbsp; # necessary</div><div>&nbsp; &nbsp; END</div><div>&nbsp; END</div><d=
iv><br></div><div><br></div><div>I there way to let mapserver figure out th=
e hostname from the request</div><div>and create the appropiate links in th=
e WFS capabilities accordingly?</div><div><br></div><div>Something like:</d=
iv><div><br></div><div>&nbsp; WEB</div><div>&nbsp; &nbsp; METADATA</div><di=
v>&nbsp; &nbsp; &nbsp; "wfs_title"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "myser=
ver"</div><div>&nbsp; &nbsp; &nbsp; "wfs_online</div><div>resource" "{reque=
st protocol and hostname}/mapserver?"</div><div>&nbsp; &nbsp; &nbsp; "wfs_s=
rs"&nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "EPSG:4326"</d=
iv><div>&nbsp; &nbsp; &nbsp; "wfs_enable_request" "*"&nbsp; # necessary</di=
v><div>&nbsp; &nbsp; END</div><div>&nbsp; END</div><div><br></div><div><br>=
</div><div>-Matthias</div><div><br></div><div>_____________________________=
__________________</div><div>mapserver-users mailing list</div><div><a href=
=3D"mailto:[email protected]">[email protected]=
</a></div><div><a href=3D"https://lists.osgeo.org/mailman/listinfo/mapserve=
r-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a></div>=
</blockquote><div><br></div><div><br></div></blockquote></body></html>

--=-gtYWbIIKDr5EFpSYoGC/--


--===============6578236502292348440==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbWFwc2VydmVy
LXVzZXJzIG1haWxpbmcgbGlzdAptYXBzZXJ2ZXItdXNlcnNAbGlzdHMub3NnZW8ub3JnCmh0dHBz
Oi8vbGlzdHMub3NnZW8ub3JnL21haWxtYW4vbGlzdGluZm8vbWFwc2VydmVyLXVzZXJz

--===============6578236502292348440==--