[OpenLayers-Users] GeoServer, Openlayers, Windows - Proxy Hell I think?

Mr. Puneet Kishor punk.kish at gmail.com
Thu Sep 29 09:22:12 EDT 2011


On Sep 28, 2011, at 9:56 AM, bsheehy wrote:

> I'm using GeoServer to server maps and Openlayers to display them in a .Net
> Website. Its all installed on Windows Server 2003 with my my site that uses
> OpenLayers hosted by IIS.I use WFS and WMS services. Even though they are on
> the same server, I think the different ports 80 for IIs and 8080 for
> GeoServer constitute different domains. 
> Do I need to use a Proxy?
> 
> Can someone point me to some idiot proof help that shows me how to set this
> up - because I'm totally lost.
> 

Other than OpenLayer, I don't use any of the above mentioned technologies (GeoServer, Windows), so I can't help you with the specifics, but I can explain the basics behind what is required and why.

When a user requests a web page from server A, usually everything that the user sees in the browser comes from A. But, because of the nature of www, it doesn't have to. Images, scripts, text all can come from different servers. All was well, until the arrival of Ajax. Ajax allows JavaScript to query servers asynchronously and load more data, manipulate the web page. This is what OpenLayers does.

Because of security reasons (you can search for "cross-site scripting vulnerabilities" to learn more), browsers permit scripts to load data from the same domain where the page originated. So, scripts in your page above, can only load data from server A.

However, your GeoServer is serving data from port 8080, hence, it is really a different server (to the outside world) even if it is running on the same physical server, or even the same web server. So, your JavaScript embedded in a page delivered by server A is trying to request data from server B. That is not allowed.

To get around this, you can use two techniques -- one is called JSONP, and the other is the use of a proxy.

The idea behind a proxy is that your JavaScript will think that it is requesting data from server A, but the proxy will actually request it from B and send it back to the web page.

With the above understanding, you can search around for implementing proxies on Windows, and hopefully go your merry way.

--
Puneet Kishor



More information about the Users mailing list