[mapserver-users] Internal Server Error / proxy.cgi Fixed

Simone Lella lella.s at irea.cnr.it
Thu Sep 30 00:18:19 PDT 2010


  I've installed Python 2.7 and I've changed the first row of 
"Proxy.cgi" file with "#! C:/Python27/python.exe -u"

Simone

Simone Lella
Istituto per il Rilevamento Elettromagnetico dell'Ambiente
IREA - CNR (http://www.irea.cnr.it)
Via Bassini, 15
Tel. +39 02-23699299
Milano


Il 23/09/2010 11:13, Simone Lella ha scritto:
> Hi,
>
> I'm using MS4W with Windows 7.
> When I call "http://localhost:8081/cgi-bin/proxy.cgi", the response is:
>
> /Internal Server Error
> /
>
> /The server encountered an internal error or misconfiguration and was 
> unable to complete your request./
>
> /Please contact the server administrator, admin at local.domain and 
> inform them of the time the error occurred, and anything you might 
> have done that may have caused the error./
>
> /More information about this error may be available in the server 
> error log.
> /
>
>
> The "error.log" file contains:
>
> /[Thu Sep 23 09:49:43 2010] [warn] PassEnv variable PYTHONPATH was 
> undefined
> [Thu Sep 23 09:49:43 2010] [notice] Apache/2.2.10 (Win32) configured 
> -- resuming normal operations
> [Thu Sep 23 09:49:43 2010] [notice] Server built: Oct 10 2008 12:39:04
> [Thu Sep 23 09:49:43 2010] [notice] Parent: Created child process 2932
> [Thu Sep 23 09:49:43 2010] [warn] PassEnv variable PYTHONPATH was 
> undefined
> [Thu Sep 23 09:49:44 2010] [warn] PassEnv variable PYTHONPATH was 
> undefined
> [Thu Sep 23 09:49:44 2010] [notice] Child 2932: Child process is running
> [Thu Sep 23 09:49:44 2010] [notice] Child 2932: Acquired the start mutex.
> [Thu Sep 23 09:49:44 2010] [notice] Child 2932: Starting 64 worker 
> threads.
> [Thu Sep 23 09:49:44 2010] [notice] Child 2932: Starting thread to 
> listen on port 8081.
> [Thu Sep 23 09:50:13 2010] [error] [client 127.0.0.1] (OS 
> 2)Impossibile trovare il file specificato.  : couldn't create child 
> process: 720002: proxy.cgi
> [Thu Sep 23 09:50:13 2010] [error] [client 127.0.0.1] (OS 
> 2)Impossibile trovare il file specificato.  : couldn't spawn child 
> process: C:/ms4w/Apache/cgi-bin/proxy.cgi/
>
>
> The "proxy.cgi" file was created in "C:/ms4w/Apache/cgi-bin/proxy.cgi" 
> and I've copied into the following text:
>
> /#!/usr/bin/env python
>
> """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', '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',
>                 'v-swe.uni-muenster.de:8080',
>                 'vmap0.tiles.osgeo.org','localhost:8081']
>
> 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 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()
>         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/
>
>
> I've modified "proxy.cgi" file at "allowedHosts" by adding 
> "localhost:8081".
>
> I must modify the first row of "proxy.cgi" file?
> Can this issue related to the Windows 7 OS?
>
>
> Thanks
>
> Simone
>
>
>   *_
>   _*
>
>
>
> -- 
> Simone Lella
> Istituto per il Rilevamento Elettromagnetico dell'Ambiente
> IREA - CNR (http://www.irea.cnr.it)
> Via Bassini, 15
> Tel. +39 02-23699299
> Milano
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100930/b335e29a/attachment.htm>


More information about the MapServer-users mailing list