User:Kannix/tilestache

From OpenStreetMap Wiki
Jump to navigation Jump to search

tilestache mod_python on parallels PLESK

Had a hard time getting tilestache running under mod_python on my plesk machine: 404 Not Found error :-(
(tested on plesk 11 / plesk 12)

This should work:

  • make sure, mod_python is installed:
    • server settings > tools & settings > plesk > updates and upgrades > Add/Remove Components > Web hosting features > Apache mod_python module
  • check domain settings:
    • Hosting Services > Domains > [yourdomain.tld] > Manage Hosting > Websites & Domains > show more > hosting settings > UNCHECK Python support
    • checking 'python support' leads plesk to add this to /var/www/vhosts/system/[yourdomain.tld]/conf/httpd.conf (httpd.conf is autogenerated by plesk and not editable by user!)
           <IfModule mod_python.c>
               <Files ~ (\.py$)>
                   SetHandler python-program
                   PythonHandler mod_python.cgihandler
               </Files>
           </IfModule>
  • add custom httpd directives:
    • Hosting Services > Domains > [yourdomain.tld] > Manage Hosting > Websites & Domains > show more > Web Server Settings > Additional directives for HTTP
<Directory /var/www/vhosts/[yourdomain.tld]/httpdocs>
   AddHandler mod_python .py
   PythonHandler TileStache::modpythonHandler
   PythonOption config /etc/tilestache.cfg
</Directory>

tilestache and nginx on parallels PLESK

serving-your-map-tiles-30-times-faster

  • make sure, nginx is installed:
    • server settings > tools & settings > plesk > updates and upgrades > Add/Remove Components > Web hosting features > Nginx web server and reverse proxy support
  • add custom httpd directives:
    • Hosting Services > Domains > [yourdomain.tld] > Manage Hosting > Websites & Domains > show more > Web Server Settings > nginx settings
      • check 'Smart static files processing'
      • check 'Serve static files directly by nginx' and remove png from list
      • Additional nginx directives:
location  ~ ^\/tiles.py\/(?<tile_path>.*)$ {
   alias /tmp/stache/;
   log_not_found off;
   expires 30d;
   add_header Pragma public;
   add_header Cache-Control "public";
   add_header X-Static super;
   try_files $tile_path @tilestache;
}
location @tilestache {
   log_not_found off;
   proxy_pass http://[your-server-IP]:7080;
   proxy_set_header Host $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   expires 30d;
   etag on;
   add_header X-Static miss;
}
/etc/tilestache.cfg

{
  "cache": {    "name": "Disk",
    "path": "/var/www/vhosts/grade.de/tiles.grade.de/stache",
    "umask": "0000",
    "dirs": "portable",
    "gzip": ["xml", "json"]
    },

  "layers": {

    "cemt-vector-2020": {
      "provider": 
      {
        "name": "mbtiles", 
        "tileset": "/var/www/vhosts/grade.de/tiles.grade.de/cemt_EU_2020_uc.mbtiles"
      },
      "cache lifespan": 43200
    },

    "cemt-json-tiled-uc": {
      "provider": 
      {
        "name": "mbtiles", 
        "tileset": "/var/www/vhosts/grade.de/tiles.grade.de/cemt_EU_2019_uc.mbtiles"
      },
      "cache lifespan": 43200
    },

    "vector-waterway": {
      "provider":
      {
        "name": "vector", "driver": "Spatialite",
        "parameters": {"file": "/var/www/vhosts/grade.de/tiles.grade.de/cemt_minimal.db", "layer": "cemt_polylines"}
      }
    },

    "int-chart": {
      "provider":
      {
        "name": "vector", "driver": "GeoJSON",
        "parameters": {"file": "/var/www/vhosts/grade.de/tiles.grade.de/int-chart.geojson"}
      }
    },

    "NAUTHIS_SkinOfEarth": {
      "provider":
      {
        "name": "url template",
        "template": "https://www.geoseaportal.de/wss/service/NAUTHIS_SkinOfTheEarth/guest?LAYERS=18&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 53.7,
        "lon": 7.52,
        "zoom": 8
      }
    },

    "NAUTHIS_AidsAndServices": {
      "provider":
      {
        "name": "url template",
        "template": "http://www.geoseaportal.de/wss/service/NAUTHIS_AidsAndServices/guest?LAYERS=82,81,80,78,77,76,74,73,72,71,70,69,68,67,66,65&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 53.7,
        "lon": 7.52,
        "zoom": 8
      }
    },

    "NAUTHIS_Hydrography": {
      "provider":
      {
        "name": "url template",
        "template": "http://www.geoseaportal.de/wss/service/NAUTHIS_Hydrography/guest?LAYERS=134,133,132,130,129,128,127,126,125,124,123,122,121,119,118,114,113,112,111,110&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 53.7,
        "lon": 7.52,
        "zoom": 8
      }
    },

    "diepte_noordzee": {
      "provider":
      {
        "name": "url template",
        "template": "https://geoservices.rijkswaterstaat.nl/apps/geoserver/diepte_noordzee/ows?SERVICE=WMS&FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=diepte_noordzee:diepte_gegevens_noordzee_varierende_resolutie&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 53.7,
        "lon": 7.52,
        "zoom": 8
      }
    },

    "ncp_diepte14": {
      "provider":
      {
        "name": "url template",
        "template": "http://geoservices.rijkswaterstaat.nl/noordzee_bathymetry_in_lat_vector?LAYERS=ncp_diepte14&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 53.7,
        "lon": 7.52,
        "zoom": 8
      }
    },

    "dieptelijn_50dm15": {
      "provider":
      {
        "name": "url template",
        "template": "http://geoservices.rijkswaterstaat.nl/noordzee_bathymetry_in_lat_vector?LAYERS=dieptelijn_50dm15&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 53.7,
        "lon": 7.52,
        "zoom": 8
      }
    },

    "ijg_diep_2013": {
      "provider":
      {
        "name": "url template",
        "template": "http://geoservices.rijkswaterstaat.nl/ijsselmeergebied_diepte?LAYERS=ijg_diep_2013&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A3857&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 52.693,
        "lon": 5.597,
        "zoom": 8
      }
    },

    "GEBCO": {
      "provider":
      {
        "name": "url template",
        "template": "http://osm.franken.de:8080/geoserver/gwc/service/wms?LAYERS=gebco_new&FORMAT=image%2Fjpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A900913&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 52.693,
        "lon": 5.597,
        "zoom": 3
      }
    },

    "10m_tracks": {
      "provider":
      {
        "name": "url template",
        "template": "http://osm.franken.de/cgi-bin/mapserv.fcgi?LAYERS=trackpoints_cor1_test_dbs_10%2Ctrackpoints_cor1_test_10%2Ctest_zoom_10_cor_1_points_10%2Ctest_zoom_9_cor_1_points_10%2Ctest_zoom_8_cor_1_points_10%2Ctest_zoom_7_cor_1_points_10%2Ctest_zoom_6_cor_1_points_10%2Ctest_zoom_5_cor_1_points_10%2Ctest_zoom_4_cor_1_points_10%2Ctest_zoom_3_cor_1_points_10%2Ctest_zoom_2_cor_1_points_10&NUMZOOMLEVELS=22&PROJECTION=EPSG%3A900913&TYPE=png&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A900913&BBOX=$xmin,$ymin,$xmax,$ymax&WIDTH=$width&HEIGHT=$height"
      },
      "preview": {
        "lat": 52.693,
        "lon": 5.597,
        "zoom": 8
      }
    },


    "cemt": {
      "provider": 
      {
        "name": "mbtiles", 
        "tileset": "/var/www/vhosts/grade.de/tiles.grade.de/cemt.mbtiles"
      },
      "cache lifespan": 43200
    },

    "seamark": {
      "provider":
      {
        "name": "proxy", 
        "url": "http://t1.openseamap.org/seamark/{Z}/{X}/{Y}.png"
      },
      
      "cache lifespan": 43200
    },

    "openriverboatmap": {
      "provider":
      {
        "name": "proxy", 
        "url": "http://a.tile.openstreetmap.fr/openriverboatmap/{Z}/{X}/{Y}.png"
      },
      "cache lifespan": 43200
    }
  },
  "logging": "critical"
}