I can't understand why we use proxy (OpenLayers.ProxyHost
) for WMS GetFeatureInfo request in OpenLayers. I am using OpenLayers 2.10, Apache-Tomcat-6.0.35 and GeoServer.
Why we use proxy? How should use?
I am new to web development.
to avoid the cross origin policy that prevents evil sites from stealing your credit card details by accident. See http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#WhydoIneedaProxyHost for more details.
Due to security restrictions in Javascript, it is not possible to retrieve information from remote domains via an XMLHttpRequest.
Classes like WFS and GeoRSS use XMLHTTPRequest to get their data. If they are querying a remote server (anything other than the machine hosting your page), you must install a proxy script somewhere web accessible on that machine. See below for how to set up your own ProxyHost.
If the OpenLayers.ProxyHost variable is not set to a valid proxy host, requests are sent directly to the remote servers. In most cases, the result will be a security exception, although this exception often occurs silently.