[[TOC(ConfigureProxy)]] = Proxy Configuration = If your web pages are not served by the server running the server side !MapFish services, you will need to configure a proxy to work around the [http://en.wikipedia.org/wiki/Same_origin_policy same origin policy]. Two methods are described in the following sections, but the first one is recommended. == Apache mod_proxy == If your web pages are served by apache, use [http://httpd.apache.org/docs/1.3/mod/mod_proxy.html mod_proxy]. For that, you need to check that mod_proxy is enabled. On a Debian/Ubuntu system, you do that by running the following command as root: {{{ a2enmod rewrite a2enmod proxy a2enmod proxy_http }}} Then, you must add some lines to your server configuration, inside the {{{}}} section of your choice (for the default website on Debian/Ubuntu, you edit the {{{/etc/apache2/sites-enabled/000-default}}} file). === Example with local services, but on different ports === The apache configuration: {{{ RewriteEngine On RewriteRule /pylons/(.*) http://localhost:5000/$1 [P] RewriteRule /tomcat/(.*) http://localhost:8180/$1 [P] Order allow,deny Allow from all }}} Don't forget to replace {{{localhost}}} and the port numbers if it's not what you want. Make apache reload it's configuration (on Debian/Ubuntu, run {{{apache2ctl graceful}}} as root). Now, you can test your proxy with this URL (if you have tomcat installed with the print servlet): http://localhost/tomcat/print-servlet-1.1/ The client side (don't forget that the HTML pages must be served by the same virutalHost the proxy is configured on) must be configured like that (in the {{{client/examples/examples.js}}} file): {{{ OpenLayers.ProxyHost = null; mapfish.SERVER_BASE_URL = '/pylons/'; }}} If you want to use the tomcat print service, you have to configure your print widgets like that: {{{ { xtype: 'print-simple', ... configUrl: '/tomcat/print-servlet-1.1/pdf/info.json', ... } }}} === Example with the services from demo.camptocamp.com === For example, put that if you want to use the demo.camptocamp.org infrastructure: {{{ RewriteEngine On RewriteRule /demo/(.*) http://demo.mapfish.org/mapfishsample/1.1/$1 [P] Order allow,deny Allow from all }}} Make apache reload it's configuration (on Debian/Ubuntu, run {{{apache2ctl graceful}}} as root). Now, you can test your proxy with this URL: http://localhost/demo/mapfish.png The client side (don't forget that the HTML pages must be served by the same virutalHost the proxy is configured on) must be configured like that (in the {{{client/examples/examples.js}}} file): {{{ OpenLayers.ProxyHost = null; mapfish.SERVER_BASE_URL = '/demo/'; }}} == proxy.cgi script == Copy the client/examples/proxy.cgi script in you apache CGI directory (on Debian/Ubuntu, it's located in {{{/usr/lib/cgi-bin}}}) and make sure it's executable ({{{chmod a+rx /usr/lib/cgi-bin/proxy.cgi}}}). By default, your apache should be configured to run that as a script. Your configuration should already contain something like that: {{{ ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all }}} Then, you must edit the proxy.cgi script to add the list of hosts you want to allow on the following line: {{{ allowedHosts = ['demo.mapfish.org', 'localhost:5000'] }}} Now, you can test your proxy with this URL: http://localhost/cgi-bin/proxy.cgi?url=http://demo.mapfish.org/mapfishsample/1.1/mapfish.png The client side (don't forget that the HTML pages must be served by the same virutalHost the proxy is configured on) must be configured like that (in the {{{client/examples/examples.js}}} file): {{{ OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url="; mapfish.SERVER_BASE_URL = 'http://demo.mapfish.org/mapfishsample/trunk/'; }}}