Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

There have been several questions very similar to this asked already (including ones not involving GeoServer), but their solutions have not solved my problem. I am trying to use getFeatureInfo on my GeoServer WMS layers, which are hosted on a different domain than the website on which they will be used, and have since learned that I need a proxy to accomplish this.

I have followed the instructions on how to set this up in Tomcat 6 (except for renaming .jar file as it's unnecessary in v6), added www.greengeography.org and the IP of my local network to the proxy.cgi file, then changed the top line to #!/usr/bin python as that's where it's at in Amazon's EC2 Linux (and also tried a slash instead of space as I've seen both ways).

I am confused on URL mapping, servlet mapping, and where to create a cgi directory, so I tried it in just about every location within the /tomcat6/webapps, including the main geoserver directory. The only place I am able to access the cgi file in a browser is at the root. Why can I not make this happen in the geoserver directory, which is where I think it needs to be? I did not see instructions about changing the URL mapping, so I'm not positive it's the problem.

As suggested in several other questions posted on this site, I attempted to install the GeoServer Proxy Extension instead of configuring this stuff manually, but every time I tried to access it from the GS admin page, I got java errors (no matter which version of the extension I tried), so I gave up and went back to manual.

If it helps, here is some of my javascript, and I have tried just about every URL variation I could think of:

OpenLayers.ProxyHost="http://50.112.123.161:8080/geoserver/cgi-bin/proxy.cgi?url=";

And the GeoExt part:

var featureInfo = new OpenLayers.Control.WMSGetFeatureInfo({
             url: 'http://50.112.123.161:8080/geoserver/gwc/service/wms',
             queryVisible: true,    
             exceptions: "application/vnd.ogc.se_xml",       
             layerUrls: ["http://50.112.123.161:8080/geoserver/OR_wild_wkspc/wms","http://50.112.123.161:8080/geoserver/gwc/service/wms"],
                eventListeners: {
                    getfeatureinfo: function(e) {
                         new GeoExt.Popup({
                         title: "Feature Info",
                         width: 400,
                         height: 300,
                         autoScroll: true,
                         queryVisible: true,
                         map: map,
                         feature_count: 50,
                         lonlat: mapPanel.map.getLonLatFromPixel(e.xy),
                         html: e.text
                        }).show();
                    }
                }
        });

     mapPanel.map.addControl(featureInfo);
     featureInfo.activate();

I have also been getting these errors in my GeoServer logs:

2012-02-13 23:52:22,922 ERROR [config.XMLConfiguration] - Configuration file cannot be read or does not exist!
2012-02-13 23:52:22,923 ERROR [layer.TileLayerDispatcher] - Configuration /usr/share/tomcat6/webapps/geoserver/../resources contained no layers.
2012-02-13 23:52:22,924 ERROR [layer.TileLayerDispatcher] - Error reading service information from /usr/share/tomcat6/webapps/geoserver/../resources: Error parsing file /usr/share/tomcat6/webapps/geoserver/../resources/geowebcache.xml

I also get ones when a file cannot be found. This one happens to be an html file since it was just a test to see if I could figure out the paths, but the rest of them are for proxy.cgi:

2012-02-13 19:50:22,785 WARN [servlet.PageNotFound] - No mapping found for HTTP request with URI [/geoserver/OR_wild_wkspc/test.html] in DispatcherServlet with name 'dispatcher'

Last but not least, I also tried more paths to point to the .cgi file, as suggested here. But no matter what, I get this error in Chrome Developer:

XMLHttpRequest cannot load http://50.112.123.161:8080/proxy.cgi?url=http://50.112.123.161:8080http%3A%2F%2F50.112.123.161%3A8080%2Fgeoserver%2FOR_wild_wkspc%2Fwms%3FSERVICE%3DWMS%26VERSION%3D1.1.1%26REQUEST%3DGetFeatureInfo%26LAYERS%3DOR_wild_wkspc%253AExistingWildWebMerc%2COR_wild_wkspc%253AProposedWildWebMerc%26QUERY_LAYERS%3DOR_wild_wkspc%253AExistingWildWebMerc%2COR_wild_wkspc%253AProposedWildWebMerc%26STYLES%3D%2C%26BBOX%3D-14061041.537506%252C5096118.80202%252C-12776899.462494%252C5842144.19798%26FEATURE_COUNT%3D10%26HEIGHT%3D610%26WIDTH%3D1050%26FORMAT%3Dimage%252Fpng%26INFO_FORMAT%3Dtext%252Fhtml%26SRS%3DEPSG%253A900913%26X%3D409%26Y%3D296. Origin http://www.greengeography.org is not allowed by Access-Control-Allow-Origin. OpenLayers.js:516Uncaught TypeError: Cannot read property 'x' of null

If you feel I should've been able to solve this given that there have been so many similar questions asked already, that's fine, but please don't downvote it, because I did do my research. Thanks!

share
    
where to put cgi-bin folder ??? –  bgc Feb 19 at 11:08
    
Sorry, I don't have my server set up anymore, and I can't recall off the top of my head where to place that directory... –  travelampel Feb 19 at 23:10

1 Answer 1

up vote 2 down vote accepted

You should be pointing OpenLayers to a local proxy. Not the proxy on GeoServer.

For example, my OpenLayers.ProxyHost property is like:

OpenLayers.ProxyHost = "proxy/proxy.ashx?url=";

But you might want something like this:

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

Documentaion

enter image description here

share
    
@travelampel Did placing the proxy cgi in your openlayers local machine work? –  CaptDragon Feb 20 '12 at 19:52
    
YES, thank you for the input, and sorry for the delayed reply. However, the website on which the map will ultimately be placed may not be very accessible to me in terms of doing anything but adding an html file. That said, I ended up making the map on the same domain as my GeoServer, then using a full-page iframe on the destination site: greengeography.org/projects/oregonwild/tests/test2.html . I realize how cheeky this is, but it seems to work and bypasses the cross-domain issue entirely. –  travelampel Mar 11 '12 at 21:03

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .