1

I want to dispaly my layers on a server. I'am using geoserver 2.3.2 and apache 2.4

Till now i Create a proxy file in referring in this link : http://trac.osgeo.org/openlayers/browser/trunk/openlayers/examples/proxy.cgi and i Put it in cgi-bin folder. I Installed python and in the starting line of proxy.cgi i put the location of python. #!C:/Python27/python.exe -u

I found in some tutorials that i should configure the file httpd.conf and i have no idea how to configure it and where should i add this code :

" ProxyRequests Off ProxyPreserveHost On

Order deny,allow

Allow from all

ProxyPass /geoserver //localhost:8080/geoserver

ProxyPassReverse /geoserver //localhost:8080/geoserver "

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Mar 10, 2014 at 16:24

1 Answer 1

2

Those settings look like they belong to an Apache 2.2 server. For your Apache 2.4 server you could instead try:

ProxyRequests Off
ProxyPreserveHost On
<Proxy /geoserver>
Require all granted
</Proxy>
ProxyPass /geoserver http://127.0.0.1:8080/geoserver
ProxyPassReverse /geoserver http://127.0.0.1:8080/geoserver

Which are part of the configuration settings for Apache and added to the httpd.conf file.

You could try also using the server IP or localhost instead of 127.0.0.1 in the ProxyPass and ProxyPassReverse sections, i.e.

ProxyPass /geoserver http://localhost:8080/geoserver
ProxyPassReverse /geoserver http://localhost:8080/geoserver

or

ProxyPass /geoserver http://<your server ip>:8080/geoserver
ProxyPassReverse /geoserver http://<your server ip>:8080/geoserver

To test whether the proxying of GeoServer via Apache is working you should browse to:

http://localhost/geoserver/web/

If this page opens then the Apache web server is correctly proxying the the GeoServer server.

To help you debug any issues with the Apache configuration open a command window and try:

httpd.exe -t

If you get an error "is not recognized as an internal or external command" then the Apache httpd.exe is not in your path, you will need to change to the directory that holds the httpd.exe file before running the command. The typical location for the httpd.exe file would be in the bin sub folder such as:

* C:\Apache24\bin\

Check too that at the top of the httpd.conf file that you have uncommented (remove the #) the modules that handle proxying like:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Answering other questions raised in the comments:

The call to the proxy.cgi file (like below) needs to go into your JavaScript code called by the HTML page in which you create your map.

OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=..."

The proxy.cgi file itself doesn't need to be placed in the cgi-bin folder of the Apache server; it can go anywhere but you need to enable this by editing the following directive in the Apache httpd.conf file like below (where "C:/Apache24/htdocs" is taken to be the document root).

<Directory "C:/Apache24/htdocs">
 # The Options directive is both complicated and important. 
 # Please see http://httpd.apache.org/docs/2.4/mod/core.html#options
 #Options +FollowSymLinks +Includes
 # Adding +ExecCGI allows CGI scripts to run outside of cgi-bin (and similar) script folders
 Options +FollowSymLinks +Includes +ExecCGI
 AllowOverride None
 Require all granted
</Directory>

To enable the proxy.cgi file to be recognized as executable you need to uncomment the appropriate AddHandler section (within the <IfModule mime_module> section), like:

<IfModule mime_module>
 ...
 # AddHandler allows you to map certain file extensions to "handlers":
 # actions unrelated to filetype. These can be either built into the server
 # or added with the Action directive (see below)
 #
 # To use CGI scripts outside of ScriptAliased directories:
 # (You will also need to add "ExecCGI" to the "Options" directive.)
 #
 # Enabling the below to allow python processing
 AddHandler cgi-script .cgi .py
 ...
</IfModule>

You need to restart Apache for the configuration changes to be enabled.

You can test that the proxy.cgi is working by browsing to it like (below), without any parameters.

http://localhost/cgi-bin/proxy.cgi

The page should redirect you to the OpenLayers home page, or whatever url you have set in the proxy.cgi section:

else:
 fs = cgi.FieldStorage()
 url = fs.getvalue('url', "http://www.openlayers.org")

For a working example of a Web page with OpenLayers using a proxy.cgi script see: GeoRSS Example

answered Mar 10, 2014 at 16:37
19
  • 1
    thanks for reply..but where should i add the code exactly ?!! Commented Mar 10, 2014 at 16:40
  • At the bottom your httpd.conf file. Commented Mar 10, 2014 at 16:42
  • 1
    after those modification when i want to start my apache, an error message come up whit : "The requested operation has failed!" do i miss something or what ?! Commented Mar 10, 2014 at 17:01
  • It's difficult to say without knowing the whole configuration. Before you made the change to the Apache configuration were both the Apache http server (127.0.0.1) and the Java (Tomcat?) server (127.0.0.1/geoserver) working for you? Do you get any warning if you use: httpd.exe -t in the command window? Commented Mar 10, 2014 at 17:13
  • 1
    nn (127.0.0.1/geoserver) didn't work for me !! here is what it works for me : localhost:8080/geoserver/web !! what about tomcat should i install Tomcat too Commented Mar 11, 2014 at 10:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.