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.

I am having problems getting WFS data to display on a map using OpenLayers/GeoExt/GeoServer.

I created a proxy script like on this page:

http://trac.osgeo.org/openlayers/browser/trunk/openlayers/examples/proxy.cgi

I have put this is file in C:\Program Files\GeoServer 2.0.2\webapps\geoserver.

I have changed the path at the top line of the file to read

#!C:/Python26/python.exe -u

I have also added the address of the machine that I want to allow to the file (10.0.0.155:8080) and added an environment variable for python (the machine is running Windows XP).

When I point to the proxy.cgi in a web browser it just displays the proxy.cgi file in the web browser, when from what I have read it should be showing the OpenLayers homepage.

Does anyone know how I can get this to work?

Regards,

James

share|improve this question
1  
Running a Python CGI script inside of Tomcat is probably not going to work like that. The script is designed for people using Apache HTTPD to host their sites, not Tomcat. You'll need to do something different. –  Christopher Schmidt Oct 13 '10 at 14:18

4 Answers 4

up vote 2 down vote accepted

GeoServer doesn't provide a CGI folder so you either need to put the proxy script in you main server's CGI folder (if you are using Apache to serve GeoServer to the web) or go with the GeoServer proxy plugin http://geoserver.org/display/GEOS/GeoServer+Proxy+Extension that provides the same functionality with in the GeoServer environment.

share|improve this answer
    
Thanks for the help. Do I have to add a MIME type for WFS in the GeoServer proxy extension or will the ones already set up cover me? –  James S Oct 13 '10 at 15:49
    
I've never actually used it but I imagine it will work for WFS out of the box. –  iant Oct 13 '10 at 18:48
    
My webserver and geoserver are on 10.0.0.155:8080. My PostGIS install is on on the same machine, using port 5432. What host do I need to add in the geoserver proxy extension to make this work? And do I have to add the OpenLayers.Proxy line in my web page? –  James S Oct 14 '10 at 10:50
1  
I don't think you need a proxy in that case. You would need a proxy if you were serving your web page from a different machine than the one that has GeoServer on it. (PostGIS is irrelevant). –  iant Oct 14 '10 at 14:00
    
I had also same problem.I had geoserver on port 8080 ,glassfish on port 9999.My OS is Windows 7.WHere should i put the "proxy.cgi" file ??Since there is no cgi-bin folder.. –  Nahom_Pain Nov 2 '11 at 14:43

Yes. You have to add the OpenLayers.Proxy to your web page. Is your web server IIS or apache? in the script you need to add 10.1.1.155:8080. I would also add 10.1.1.155 to the script.

share|improve this answer
    
I am using the web server that came with GeoServer when I installed it. I have added OpenLayers.ProxyHost="10.0.0.155:8080/geoserver/rest/proxy?url=";; to the web page, I am using the address 10.0.0.155:8080/geoserver/rest/proxy?url=http://10.0.0.155:8080/… to access this web page but it is still not working. –  James S Oct 14 '10 at 13:36

You need a local server like apache something like that then u add your project in htdocts in apache after that u can user proxy like that

OpenLayers.ProxyHost = "/gt/proxy.cgi?url=";

share|improve this answer

If you have access to both webservers it might be just easier to add the appropriate headers for your situation:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Authorization, X-Requested-With
Access-Control-Allow-Methods:GET, OPTIONS
Access-Control-Allow-Origin:http://your.origin.domain

You'll notice the browser performing 2 request after that: the first is a OPTION type call, the second a GET (in this case)

I only know how to do this -for sure- in nginx, for a live working example see: http://m.bitless.be/

open the debugger/webtools (in chrome ctrl+shift+i) and check out the XHR section. spot the traffic layer. I've set it up in a way that all domains should be able to access it automatically.

## Only allow OPTIONS and HEAD and GET request methods
if ($request_method ~ ^(OPTIONS|HEAD)$ ) {
    add_header Access-Control-Allow-Origin $http_origin;
    add_header Access-Control-Allow-Methods "GET, OPTIONS";
    add_header Access-Control-Allow-Headers "Authorization, X-Requested-With";
    add_header Access-Control-Allow-Credentials "true";
    add_header Content-Length 0;
    add_header Content-Type text/plain;
    return 200;
}
if ($request_method ~ ^(GET)$ ) {
    add_header Access-Control-Allow-Origin $http_origin;
    add_header Access-Control-Allow-Methods "GET, OPTIONS";
    add_header Access-Control-Allow-Headers "Authorization, X-Requested-With";
    add_header Access-Control-Allow-Credentials "true";
}

It's an alternative answer for your question: "How can I get this to work". That's how I eventually did it, even after writing my own proxy script, I find this way to suit my goals better, not having to worry about crossdomain restrictions in openlayers.

Needless to say: you need access to all webservers serving layer data.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.