[MapProxy] Re: Nginx, TMS and missing tiles

Larry Shaffer larrys at dakotacarto.com
Sat Jan 28 12:14:41 EST 2012


Hi Luca,

It's my understanding that the URL for MapProxy's TMS service is
<mapproxy location or domain>/tms/ which returns tiles like:

http://localhost/mapproxy/tms/1.0.0/MyMap_EPSG32613/0/0/0.png

Doing a try_files against such a URL will no doubt fail, unless, for
whatever reason, your www public directory structure exactly matches
that path. To test against the tiles actual location, I'm guessing you
will have to do something like the following in your Nginx config:

1) store current URI in a variable

2) rewrite the URI to match tile's potentially real path location

3) use try_files to test for existing file using rewritten URI

4) if tile exists, serve it, otherwise, reset the URI to original

5) proxy pass to MapProxy

Since MapProxy does a X-Sendfile if the file exists (correct?), I
think it's probably already pretty fast at passing off existing tiles.
Though there is the extra connection overhead, considering Nginx could
just server the tile.

Michael's suggestion of a caching approach either on the server, or
via a CDN, is an efficient solution. I use CloudFlare.com's CDN for
this and it serves my previously served TMS tiles without having to
send the request to my server, and honors the expire response headers
produced by MapProxy.

When I get to my Mac, I'll try my hand at the Nginx config, as it
would be a good choice when you don't want to cache served results.

Best regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota



On Sat, Jan 28, 2012 at 9:11 AM, Michael Shishcu <micklesh at gmail.com> wrote:
> hi Luca,
> that kind of nginx config works for me for a couple of months without any
> problem.
> I'm not sure if this is the best way but still...
> to improve the speed further, you can try to set some kind of memory cache
> on nginx side.
>
> regards, michael
>
> On Sat, Jan 28, 2012 at 6:03 PM, Luca Casagrande <luca.casagrande at gmail.com>
> wrote:
>>
>> On 28/01/2012 16:38, Luca Casagrande wrote:
>>>
>>> Hello everybody,
>>> I'd like to use nginx to serve TMS tiles generated with MapProxy but I
>>> don't understand how handle a missing tile. The idea is: if the tile is
>>> there, serve it; if not call MapProxy to generate it.
>>>
>>> Thanks for your help!
>>> L.
>>
>> What do you think about:
>> - MapProxy with Gunicorn and eventlet
>> - Nginx with something like this (taken from Gunicorn site):
>>
>>        location / {
>>            # checks for static file, if not found proxy to app
>>            try_files $uri @proxy_to_app;
>>        }
>>
>>        location @proxy_to_app {
>>            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>            proxy_set_header Host $http_host;
>>            proxy_redirect off;
>>            proxy_pass   http://app_server;
>>        }
>> This should do the the trick or not?
>>
>> Re-Thanks :)
>>
>>
>> _______________________________________________
>> MapProxy mailing list
>> MapProxy at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapproxy
>
>
>
> _______________________________________________
> MapProxy mailing list
> MapProxy at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapproxy
>


More information about the MapProxy mailing list