[OpenLayers-Users] tomcat and proxy

Lehtonen, Mika mika at digikartta.net
Wed Mar 11 02:54:02 EDT 2009


Hi,
does your cgi-bin directory work with other scripts? Is your python 
working (in that path) with other python scripts?
I don't know Vista but maybe there is a unix-like mode setting for 
files, that is, whether file can be read, wrote or/and executed. If it 
can't be executed, the proxy won't work.

- mika -

Paulo Cesar Rocha kirjoitti:
> Hi,
> I changed tomcat web.xml  and copied the proxy.cgi python script from 
> the OL example directory to the /webapps//cgi-bin/ directory (I'm 
> using Vista, Tomcat5.5 and Geoserver). When I type the url 
> http://localhost:8080/cgi-bin/proxy.cgi in IE it lists openlayers 
> proxy instead of openlayers hompage:
>   #!c:\python25\python.exe -u """This is a blind proxy that we use to 
> get around browser restrictions that prevent the Javascript from 
> loading pages not on the same server as the Javascript. This has 
> several problems: it's less efficient, it might break some sites, and 
> it's a security risk because people can use this proxy to browse the 
> web and possibly do bad stuff with it. It only loads pages via http 
> and https, but it can load any content type. It supports GET and POST 
> requests.""" import urllib2 import cgi import sys, os # Designed to 
> prevent Open Proxy type stuff. allowedHosts = ['www.openlayers.org 
> <http://www.openlayers.org>', 'openlayers.org 
> <http://openlayers.org>', 'labs.metacarta.com 
> <http://labs.metacarta.com>', 'world.freemap.in 
> <http://world.freemap.in>', 'prototype.openmnnd.org 
> <http://prototype.openmnnd.org>', 'geo.openplans.org 
> <http://geo.openplans.org>', 'sigma.openplans.org 
> <http://sigma.openplans.org>', 'localhost:8080'] method = 
> os.environ["REQUEST_METHOD"] if method == "POST": qs = 
> os.environ["QUERY_STRING"] d = cgi.parse_qs(qs) if d.has_key("url"): 
> url = d["url"][0] else: url = "http://www.openlayers.org 
> <http://www.openlayers.org/>" else: fs = cgi.FieldStorage() url = 
> fs.getvalue('url', "http://www.openlayers.org 
> <http://www.openlayers.org/>") try: host = url.split("/")[2] if 
> allowedHosts and not host in allowedHosts: print "Status: 502 Bad 
> Gateway" print "Content-Type: text/plain" print print "This proxy does 
> not allow you to access that location (%s)." % (host,) print print 
> os.environ elif url.startswith("http://") or 
> url.startswith("https://"): if method == "POST": length = 
> int(os.environ["CONTENT_LENGTH"]) headers = {"Content-Type": 
> os.environ["CONTENT_TYPE"]} body = sys.stdin.read(length) r = 
> urllib2.Request(url, body, headers) y = urllib2.urlopen(r) else: y = 
> urllib2.urlopen(url) # print content type header i = y.info 
> <http://y.info>() if i.has_key("Content-Type"): print "Content-Type: 
> %s" % (i["Content-Type"]) else: print "Content-Type: text/plain" print 
> print y.read() y.close() else: print "Content-Type: text/plain" print 
> print "Illegal request." except Exception, E: print "Status: 500 
> Unexpected Error" print "Content-Type: text/plain" print print "Some 
> unexpected error occurred. Error text was:", E
> What's wrong?
> Tia. 
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   




More information about the Users mailing list