[GIS] How to configure Proxy.cgi file for Geoserver On Tomcat

geoserveropenlayers-2web-mappingwfswms

I have a web map application in my local machine(windows xp and dont have IIS) and I have postgis data in Geoserver on Tomcat (Ubuntu). To get the WMSgetfeatureInfo, I have configured the proxy.cgi file in Geoserver (usr/lip/cgi-bin/proxy.cgi) and added my local ip address in

allowedHosts = ['xxx.xxx.x.xxx', 'www.openlayers.org', 'openlayers.org', 'labs.metacarta.com', 'world.freemap.in', 'prototype.openmnnd.org', 'geo.openplans.org', 'sigma.openplans.org', 'demo.opengeo.org', 'www.openstreetmap.org', 'sample.azavea.com', 'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080', 'vmap0.tiles.osgeo.org','www.openrouteservice.org']

and added the below line in my script.

OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";

but it throws an error in chrome console:

GET localhost:3890/usr/lib/cgi-bin/….…T%3D‌​application%252Fvnd.ogc.gml%26SRS%3DEPSG%253A27700%26X%3D682%26Y%3D284 404 (Not Found) 

I dont know whether its right or wrong. Proxy.cgi should be copied in Geoserver or my machine? in which path? added my IP into allowedhosts is correct?

Please anyone suggest me to fix this issue

Best Answer

If your openlayers app is on the same domain and port of GeoServer you don't need a proxy.

It's not working because proxy.cgi is a piece of code that works on a web server (Apache, Cherokee, nginx,...). So it's not a Java application like GeoServer that runs on a servlet container (Tomcat, Jetty,...), they are completely different technologies.

One typical use case is to have a web server with your web map application and a reverse proxy with your geoserver or any other web map server so all your requests to http://yourserver.org/geoserver are proxied to http://yourserver.org:8080/geoserver. In that case, as all your requests are at the same domain (yourserver) and port (80, the default) again you don't need a proxy.