Geoserver Proxy with Apache
Today I’ve been fighting again with how to get GetFeatureInfo working in my Geoserver, Apache, Tomcat environment. It’s pretty simple actually: One needs a proxy which I put in
/usr/lib/cgi-bin/proxy.cgi
.
Proxy code can be found in OpenLayers-2.9/examples/proxy.cgi
(Download the full package of OpenLayers and use it instead of the package that ships with Geoserver). Add all necessary hosts to allowedHosts list.
Don’t forget to set it executable:
sudo chmod +x /usr/lib/cgi-bin/proxy.cgi
To tell your website to use the proxy, add the following javascript line:
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";