This installation guide has been established using the following system configuration:
- Windows Server 2003
- Java JRE build 1.6.0_29-b11
- Tomcat version 6.0.33 (Windows Service Installer)
- The CGI-Proxy is written in Python
1. Download the
proxy.cgi file from the OpenLayers web site:
http://trac.osgeo.org/openlayers/browser/trunk/openlayers/examples/proxy.cgi
Comment: This file is also included in the OpenLayers API download:
http://trac.osgeo.org/openlayers/wiki/HowToDownload
2. Modify the
proxy.cgi file to include your domain in the
allowedHosts list:
allowedHosts = ['www.yourdomain.com:8080']
Comment: Note that you have to include domain AND port here.
3. Copy the
proxy.cgi file to the following folder:
$TOMCAT_PATH$/webapps/yourApp/WEB-INF/cgi/
4. Modify the file
web.xml of your web app by adding the sections below. You find the file at
$TOMCAT_PATH$/webapps/yourApp/WEB-INF/web.xml
Comment: In case the web.xml file doesn’t exist for your webapp, just create it yourself or copy it from another webapp and modify it.
Comment: the “param-value” for the “executable” parameter has to contain the path to your Pyhton installation.
<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<init-param>
<param-name>executable</param-name>
<param-value>c:\python25\python.exe</param-value>
</init-param>
<init-param>
<param-name>passShellEnvironment</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
5. Modify the file
context.xml of your web app by adding the element below. You find the file at
$TOMCAT_PATH$/webapps/yourApp/META-INF/context.xml
Comment: In case the context.xml file doesn’t exist for your webapp, just create it yourself or copy it from another webapp and modify it.
<Context antiResourceLocking="false" privileged="true" useHttpOnly="true" />
6. Restart Tomcat
7. To use the proxy with
OpenLayers, just include this single line into your code:
OpenLayers.ProxyHost = "/yourWebApp/cgi-bin/proxy.cgi?url=";