python - Failed to execute proxy.cgi on virtualhost apache -
i've been trying execute proxy.cgi openlayers on computer using windows 7 , xampp. when tried using localhost/mymaps/cgi-bin/proxy.cgi execute perfectly.
but when tried execute using virtualhost came
server error!
the server encountered internal error , unable complete request.
error message: couldn't create child process: 720002: proxy.cgi
i @ error log said
[thu feb 06 14:24:16 2014] [error] [client 127.0.0.1] (os 2)the system cannot find file specified. : couldn't create child process: 720002: proxy.cgi [thu feb 06 14:24:16 2014] [error] [client 127.0.0.1] (os 2)the system cannot find file specified. : couldn't spawn child process: c:/xampp/cgi-bin/proxy.cgi
this httpd-vhosts.conf file
<virtualhost *:80> serveradmin admin@sidik.com documentroot "c:\xampp\htdocs\sidik" servername sidik.com serveralias sidik.com <directory "c:\xampp\htdocs\sidik"> order allow,deny allow options indexes followsymlinks includes execcgi allowoverride </directory> </virtualhost>
this proxy.cgi
#!/python27/python.exe -u """this blind proxy use around browser restrictions prevent javascript loading pages not on same server javascript. has several problems: it's less efficient, might break sites, , it's security risk because people can use proxy browse web , possibly bad stuff it. loads pages via http , https, can load content type. supports , post requests.""" import urllib2 import cgi import sys, os # designed prevent open proxy type stuff. allowedhosts = ['www.google.co.id','www.openlayers.org','202.124.205.123:81/~vaonline', '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','172.20.110.20:83','172.20.110.20' 'vmap0.tiles.osgeo.org', 'www.openrouteservice.org', '172.20.32.11: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" else: fs = cgi.fieldstorage() url = fs.getvalue('url', "http://www.openlayers.org") try: host = url.split("/")[2] if allowedhosts , not host in allowedhosts: print "status: 502 bad gateway" print "content-type: text/plain" print print "this proxy not allow access 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 = 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 have done wrong?
although maybe coming @ late hour, here worked me anyway. specifying location of python executable application on windows, following code so; #!c:/python27/python.exe
@ top of cgi file in place of #!/python27/python.exe -u
in own case , making sure had configuration (in apache httpd.conf configuration);
<directory "c:/xampp/cgi-bin"> allowoverride options none require granted </directory>
i able cgi file work. hope helps
Comments
Post a Comment