Skip to content

Latest commit

 

History

History
 
 

nginx

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
minimal install instructions:

- configure nginx with

./configure --add-module=/path/to/mapcache/nginx

the supplied nginx.conf contains an example configuration to load mapcache.
the relevant part is:

        location ~ ^/mapcache(?<path_info>/.*|$) {
           set $url_prefix "/mapcache";
           mapcache /home/tbonfort/dev/mapserver-trunk/mapcache/mapcache.xml;
        }

the <path_info> and $url_prefix are important and are used by mapcache
to parse the incoming requests.

before running nginx, set LD_LIBRARY_PATH to where libmapcache was installed if that 
is a non standard location.

Note that nginx processes are scarse and would be locked when mapcache is doing
a curl request for a metatile, or when waiting for a metatile to be rendered.
So as not to lock down the whole nginx server in this case, mapcache will fail
with a 404 error if a requested tile cannot be found in it's cache. It is up to
the administrator of the server to forward these failed requests to an external
fastcgi or apache mapcache instance running with the same configuration file.


Here is a configuration block which forwards these 404 requests:

        location ~ ^/mapcache(?<path_info>/.*|$) {
           set $url_prefix "/mapcache";
           mapcache /path/to/etc/mapcache.xml;
           #error_page 404 = @apache_mapcache;
           error_page 404 = @fcgi_mapcache;
        }

#proxy for a mapcache instance running on another server
        location @apache_mapcache {
           proxy_pass http://localhost:8081;
# this supposes you have mapcache as a module running in an apache httpd server, where
# you would have set the httpd.conf to contain:
# MapcacheAlias /mapcache /path/to/etc/mapcache.xml;
        }

#mapcache as fcgi running with an external spawning manager (e.g. spawn-fcgi or fcgistarter)
#(make sure mapcache is built with fastcgi support)
#eg:
# export MAPCACHE_CONFIG_FILE=/path/to/etc/mapcache.xml
# /usr/local/httpd-2.4/bin/fcgistarter -c /usr/local/bin/mapcache -p 9001 -N 20

        location @fcgi_mapcache {
           fastcgi_pass   localhost:9001;
           fastcgi_param  QUERY_STRING     $query_string;
           fastcgi_param  REQUEST_METHOD   $request_method;
           fastcgi_param  CONTENT_TYPE     $content_type;
           fastcgi_param  CONTENT_LENGTH   $content_length;
           fastcgi_param  PATH_INFO        $path_info;
        }