[OpenLayers-Users] OpenLayers.ProxyHost = '/geoserver/rest/proxy?url=';

Andreas Hocevar ahocevar at opengeo.org
Thu Jul 14 10:19:56 EDT 2011


Hi,

another approach that you may find simpler: If all involved WMS
servers are under your control, and you're running a HTTP server like
Apache, Lighttpd or Nginx next to your "local" GeoServer, you can
configure your HTTP server to act as a proxy and reverse proxy, like
here: http://getsatisfaction.com/opengeo/topics/getting_wfs_response_with_javascript#reply_4776656

You would map the involved servers to different paths, e.g.

http://localhost/geoserver
http://localhost/remote_geoserver

Andreas.

On Thu, Jul 14, 2011 at 4:05 PM, Andreas Hocevar <ahocevar at opengeo.org> wrote:
> Hi,
>
> see replies inline.
>
> On Thu, Jul 14, 2011 at 3:46 PM, Morper-Busch, Lucia
> <Lucia.Morper-Busch at sbg.ac.at> wrote:
>> Hello Andreas,
>> thank you for responding.
>>
>> Yes I get prompted for credentials.
>>
>> http://myhost:8080/geoserver/rest/proxy
>> The following message appears:
>> http://myhost:8080 verlangt einen Benutzernamen und ein Passwort. Ausgabe der Website: "GeoServer Realm"
>>
>> I don't want to give everybody full access to my geoserver.
>
> You don't need to. Although this question would be better suited for
> the goeserver-users list, here's the answer: you can configure
> separate security settings for every REST endpoint in
> security/rest.properties in your GeoServer's data_dir, e.g.
>
> /rest/proxy;POST,PUT,DELETE=IS_AUTHENTICATED_ANONYMOUSLY
>
>> And what about the restriction of requesting only one host at the same time?
>
> There is no restriction like this. I'm just saying that when accessing
> resources that require HTTP Basic Auth through a simple proxy like
> this, the Authenticate headers will be sent with all subsequent
> requests, even if they go to a different target server. Once
> authenticated, this makes it (1) impossible to access target servers
> with different credentials, and (2) may expose your credentials to
> target servers that are not supposed to see them.
>
>> What's in your opinion the best solution for getting feature information of local and remote WMS layers?
>
> If you need to process feature information on the client, and your WMS
> is GeoServer with WFS enabled as well, use WFS GetFeature instead of
> WMS GetFeatureInfo, and use the Script protocol (see
> http://openlayers.org/dev/examples/cross-origin.html). If you are
> happy with the html or plain text output, use an IFrame and set its
> url to the WMS GetFeatureInfo request you want.
>
> Andreas.
>
>>
>> Greetings from Salzburg
>>
>> Lucia
>>
>>
>> Dipl.-Geogr. Lucia Morper-Busch | Researcher
>> University of Salzburg | Centre for Geoinformatics - Z_GIS
>> Schillerstr.30 | Techno-Z, Block 15, 3rd floor | 5020 Salzburg, Austria
>> Phone +43 (0)662 8044 5298 | Fax +43 (0)662 8044 5260
>>> Z_GIS...experts for the spatial view
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: andreas.hocevar at gmail.com [mailto:andreas.hocevar at gmail.com] Im Auftrag von Andreas Hocevar
>> Gesendet: Donnerstag, 14. Juli 2011 15:17
>> An: Morper-Busch, Lucia
>> Cc: openlayers-users at lists.osgeo.org
>> Betreff: Re: [OpenLayers-Users] OpenLayers.ProxyHost = '/geoserver/rest/proxy?url=';
>>
>> Hi,
>>
>> do you get prompted for credentials when you access
>> http://serverhost:8080/geoserver/rest/proxy ? If this happens, you
>> have to change the GeoServer security settings to allow unauthorized
>> access to the proxy.
>>
>> Other than that, you should not be using a proxy like this to access
>> sites that require authentication. Because the authentication headers
>> may be sent to other hosts that you access through the same proxy.
>>
>> Andreas.
>>
>> On Wed, Jul 13, 2011 at 4:55 PM, Morper-Busch, Lucia
>> <Lucia.Morper-Busch at sbg.ac.at> wrote:
>>> Hello!
>>> I want to query local and remote feature information for WMS layers.
>>> I have a server on which stays a javascript/html map viewer with ExtJs and Openlayers, in the back runs a Geoserver 2.0.2.
>>> I installed the Geoserver Proxy Extension on my server to access also a remote server.
>>> On my server the html file is in the C:\Program Files\GeoServer 2.0.2\webapps\geoserver folder.
>>> I added two hosts (without port) to the permitted hostnames: the server localhost (but with the server address not 'localhost') and a remote server host (IP address) where another geoserver is running.
>>> When I try to access the html map viewer from another PC the getfeatureinfo request requires an authentification (the geoserver username and password). And only the first host on that I try to ask the feature information gives me an reply, the other host is not responding. But when I begin with the other host it's the other way round. Like random.
>>> When I insert the url in the browser address box (http://serverhost:8080/geoserver/rest/proxy?url=getfeatureinfo-request) I have to authentificate!
>>> On the server the getfeatureinfo request works without authentification, but that's not intended.
>>> Without proxyhost I get only the feature information for the layers that are local.
>>> I tried also OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url="; But the response is only the plain text of the cgi file.
>>> Who's familiar with proxy and local/remote WMS layers?
>>> Thank you for suggestions
>>> Lucia
>>>
>>> Dipl.-Geogr. Lucia Morper-Busch | Researcher
>>> University of Salzburg | Centre for Geoinformatics - Z_GIS
>>> Schillerstr.30 | Techno-Z, Block 15, 3rd floor | 5020 Salzburg, Austria
>>> Phone +43 (0)662 8044 5298 | Fax +43 (0)662 8044 5260
>>>> Z_GIS...experts for the spatial view
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Bryan Hempen
>>> Gesendet: Samstag, 09. Juli 2011 23:42
>>> An: openlayers-users at lists.osgeo.org
>>> Betreff: [OpenLayers-Users] WFS getFeature with Filter resulting in InternalServer Error
>>>
>>> Hey!
>>>
>>> I am trying to use the example at
>>> http://openlayers.org/dev/examples/wfs-spatial-filter.html with my own
>>> WFS (UMN Mapserver) but I am having a hard time getting some problems
>>> fixed. When I load my test page for the first time OpenLayers sends the
>>> following request:
>>>
>>> <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS"
>>> version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs
>>> http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">
>>> <wfs:Query typeName="omega">
>>> <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
>>> <ogc:BBOX>
>>> <ogc:PropertyName>the_geom</ogc:PropertyName>
>>> <gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
>>> <gml:coordinates decimal="." cs="," ts=" ">135.45,-47.425
>>> 157.95,-36.175</gml:coordinates>
>>> </gml:Box>
>>> </ogc:BBOX>
>>> </ogc:Filter>
>>> </wfs:Query>
>>> </wfs:GetFeature>
>>>
>>> I get a valid response and the data is properly displayed on the map.
>>> When, however, I try to use a spatial filter in the request, like this...
>>>
>>> <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS"
>>> version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs
>>> http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">
>>> <wfs:Query xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
>>> typeName="ms:omega">
>>> <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
>>> <ogc:And>
>>> <ogc:Intersects>
>>> <ogc:PropertyName>the_geom</ogc:PropertyName>
>>> <gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
>>> <gml:outerBoundaryIs>
>>> <gml:LinearRing>
>>> <gml:coordinates decimal="." cs="," ts="
>>> ">142.28349609375,-40.5255859375 142.2615234375,-43.49189453125
>>> 148.1501953125,-44.15107421875 149.40263671875,-39.44892578125
>>> 142.28349609375,-40.5255859375</gml:coordinates>
>>> </gml:LinearRing>
>>> </gml:outerBoundaryIs>
>>> </gml:Polygon>
>>> </ogc:Intersects>
>>> <ogc:BBOX>
>>> <ogc:PropertyName>the_geom</ogc:PropertyName>
>>> <gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
>>> <gml:coordinates decimal="." cs="," ts=" ">135.45,-47.425
>>> 157.95,-36.175</gml:coordinates>
>>> </gml:Box>
>>> </ogc:BBOX>
>>> </ogc:And>
>>> </ogc:Filter>
>>> </wfs:Query>
>>> </wfs:GetFeature>
>>>
>>> ... one of the two following things will happen:
>>>
>>> 1. I get a "Internal Server Error  The server encountered an internal
>>> error or misconfiguration and was unable to complete your request." The
>>> logfile says "Premature end of script headers: mapserv.exe, referer:
>>> http://localhost/".
>>>
>>> 2. This is the response:
>>>
>>> <wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"
>>> xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
>>> xmlns:gml="http://www.opengis.net/gml"
>>> xmlns:ogc="http://www.opengis.net/ogc"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://www.opengis.net/wfs
>>> http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd
>>> http://mapserver.gis.umn.edu/mapserver
>>> http://localhost/cgi-bin/mapserv.exe?map=E:/ms4w/Apache/htdocs/mapservertest/wfs.map&amp;SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=ms:omega&amp;OUTPUTFORMAT=XMLSCHEMA">
>>>
>>> <gml:boundedBy>
>>> <gml:Box srsName="EPSG:4326">
>>> <gml:coordinates>-1.000000,-1.000000 -1.000000,-1.000000</gml:coordinates>
>>> </gml:Box>
>>> </gml:boundedBy>
>>> </wfs:FeatureCollection>
>>>
>>> Which one of the two possibilities happens appears to be random. I am
>>> using the proxy.cgi and when I run http://localhost/cgi-bin/proxy.cgi I
>>> see the OpenLayers website. Any ideas?
>>>
>>> This is how my wfs-spatial-filter.js looks like:
>>>
>>> OpenLayers.ProxyHost= "/cgi-bin/proxy.cgi?url=";
>>>
>>> .....
>>>
>>> var layer = new OpenLayers.Layer.Vector("WFS", {
>>>     strategies: [new OpenLayers.Strategy.BBOX()],
>>>     protocol: new OpenLayers.Protocol.WFS({
>>>         url:
>>> "http://localhost/cgi-bin/mapserv.exe?map=E:/ms4w/Apache/htdocs/mapservertest/wfs.map",
>>>         featureType: "omega",
>>>         featurePrefix: "ms"
>>>     })
>>> });
>>>
>>> ....
>>>
>>> The rest of the file looks exactly like in the example at
>>> http://openlayers.org/dev/examples/wfs-spatial-filter.js
>>>
>>> Thanks for your help!
>>>
>>> Bryan
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list