Sunday 16 October 2016

How to access geoserver web services on a backend server through openlayers web application hosted on another server via IIS?


I am struggling with how to access geoserver web services in my openlayers application. I setup a test machine that hosted both geoserver and the openlayers app as well as a postgres database to publish data from. I was able to just add the services as layers to my application by specifying crossorigin: anonymous. Now I need to move to a different environment where geoserver resides on a separate server, and the postgres database also resides on its own server, and these two servers are not public facing, but are on the same network as a public facing server which will host the openlayers app. When I try to access the application internally I get a CORS error and the services won't load; externally the server name included in the service url just can't be resolved. The web server is running IIS on port 80, and geoserver is running on port 8085 on its own backend machine. What do I need to do be able to see my services in my web application in this 3 tier environment?


UPDATE:


I tested the solution below, and it works (whether I set the proxy based url or not) when i am logged into a virtual machine on our network. However when I try to login to the application via a browser on a machine outside of the network, which I can do by supplying my domain credentials, the services still don't load. I get this error for each of my service URLs: Failed to load resource:net::ERR_NAME_NOT_RESOLVED.



Answer



You need to enable CORS in the servlet engine (Jetty, Tomcat?) that is running GeoServer. You will also need to set the proxy url on the global settings page to reflect the external server address (IIS) otherwise the URLs in the GetCapabilities responses will be wrong.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...