<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
I'm using MS4W with Windows 7.<br>
When I call <a class="moz-txt-link-rfc2396E" href="http://localhost:8081/cgi-bin/proxy.cgi">"http://localhost:8081/cgi-bin/proxy.cgi"</a>, the response
is:<br>
<br>
<i>Internal Server Error<br>
</i>
<p><i>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</i></p>
<p><i>Please contact the server administrator, <a class="moz-txt-link-abbreviated" href="mailto:admin@local.domain">admin@local.domain</a>
and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</i></p>
<p><i>More information about this error may be available
in the server error log.<br>
</i></p>
<p><br>
The "error.log" file contains:<br>
</p>
<p><small><small><i>[Thu Sep 23 09:49:43 2010] [warn] PassEnv
variable PYTHONPATH was undefined<br>
[Thu Sep 23 09:49:43 2010] [notice] Apache/2.2.10 (Win32)
configured -- resuming normal operations<br>
[Thu Sep 23 09:49:43 2010] [notice] Server built: Oct 10
2008 12:39:04<br>
[Thu Sep 23 09:49:43 2010] [notice] Parent: Created child
process 2932<br>
[Thu Sep 23 09:49:43 2010] [warn] PassEnv variable
PYTHONPATH was undefined<br>
[Thu Sep 23 09:49:44 2010] [warn] PassEnv variable
PYTHONPATH was undefined<br>
[Thu Sep 23 09:49:44 2010] [notice] Child 2932: Child
process is running<br>
[Thu Sep 23 09:49:44 2010] [notice] Child 2932: Acquired the
start mutex.<br>
[Thu Sep 23 09:49:44 2010] [notice] Child 2932: Starting 64
worker threads.<br>
[Thu Sep 23 09:49:44 2010] [notice] Child 2932: Starting
thread to listen on port 8081.<br>
[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<br>
[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</i></small></small></p>
<p><br>
The "proxy.cgi" file was created in
"C:/ms4w/Apache/cgi-bin/proxy.cgi" and I've copied into the
following text:<br>
</p>
<p><small><small><i>#!/usr/bin/env python<br>
<br>
"""This is a blind proxy that we use to get around browser<br>
restrictions that prevent the Javascript from loading pages
not on the<br>
same server as the Javascript. This has several problems:
it's less<br>
efficient, it might break some sites, and it's a security
risk because<br>
people can use this proxy to browse the web and possibly do
bad stuff<br>
with it. It only loads pages via http and https, but it can
load any<br>
content type. It supports GET and POST requests."""<br>
<br>
import urllib2<br>
import cgi<br>
import sys, os<br>
<br>
# Designed to prevent Open Proxy type stuff.<br>
<br>
allowedHosts = ['<a class="moz-txt-link-abbreviated" href="http://www.openlayers.org">www.openlayers.org</a>', 'openlayers.org', <br>
'labs.metacarta.com', 'world.freemap.in', <br>
'prototype.openmnnd.org',
'geo.openplans.org',<br>
'sigma.openplans.org', 'demo.opengeo.org',<br>
'<a class="moz-txt-link-abbreviated" href="http://www.openstreetmap.org">www.openstreetmap.org</a>',
'sample.azavea.com',<br>
'v-swe.uni-muenster.de:8080', <br>
'vmap0.tiles.osgeo.org','localhost:8081']<br>
<br>
method = os.environ["REQUEST_METHOD"]<br>
<br>
if method == "POST":<br>
qs = os.environ["QUERY_STRING"]<br>
d = cgi.parse_qs(qs)<br>
if d.has_key("url"):<br>
url = d["url"][0]<br>
else:<br>
url = <a class="moz-txt-link-rfc2396E" href="http://www.openlayers.org">"http://www.openlayers.org"</a><br>
else:<br>
fs = cgi.FieldStorage()<br>
url = fs.getvalue('url', <a class="moz-txt-link-rfc2396E" href="http://www.openlayers.org">"http://www.openlayers.org"</a>)<br>
<br>
try:<br>
host = url.split("/")[2]<br>
if allowedHosts and not host in allowedHosts:<br>
print "Status: 502 Bad Gateway"<br>
print "Content-Type: text/plain"<br>
print<br>
print "This proxy does not allow you to access that
location (%s)." % (host,)<br>
print<br>
print os.environ<br>
<br>
elif url.startswith(<a class="moz-txt-link-rfc2396E" href="http://">"http://"</a>) or
url.startswith(<a class="moz-txt-link-rfc2396E" href="https://">"https://"</a>):<br>
<br>
if method == "POST":<br>
length = int(os.environ["CONTENT_LENGTH"])<br>
headers = {"Content-Type":
os.environ["CONTENT_TYPE"]}<br>
body = sys.stdin.read(length)<br>
r = urllib2.Request(url, body, headers)<br>
y = urllib2.urlopen(r)<br>
else:<br>
y = urllib2.urlopen(url)<br>
<br>
# print content type header<br>
i = y.info()<br>
if i.has_key("Content-Type"):<br>
print "Content-Type: %s" % (i["Content-Type"])<br>
else:<br>
print "Content-Type: text/plain"<br>
print<br>
<br>
print y.read()<br>
<br>
y.close()<br>
else:<br>
print "Content-Type: text/plain"<br>
print<br>
print "Illegal request."<br>
<br>
except Exception, E:<br>
print "Status: 500 Unexpected Error"<br>
print "Content-Type: text/plain"<br>
print <br>
print "Some unexpected error occurred. Error text was:",
E</i><br>
</small></small></p>
<p><small><small><br>
I've modified "proxy.cgi" file at "allowedHosts" by adding
"localhost:8081".<br>
</small></small></p>
<p><small><small>I must modify the first row of "proxy.cgi" file?<br>
Can this issue related to the Windows 7 OS?</small></small><br>
</p>
<p><br>
Thanks<br>
</p>
<p>Simone<br>
</p>
<br>
<h1><b><u><small><small><small><br>
</small></small></small></u></b></h1>
<br>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
Simone Lella
Istituto per il Rilevamento Elettromagnetico dell'Ambiente
IREA - CNR (<a class="moz-txt-link-freetext" href="http://www.irea.cnr.it">http://www.irea.cnr.it</a>)
Via Bassini, 15
Tel. +39 02-23699299
Milano</pre>
</body>
</html>