Proxyfier les requêtes non prise en charge

Author:Thomas Bonfort
Contact:tbonfort at terriscope.fr

Note

This page is a work in progress.

MapCache has the ability to forward any incoming request that it cannot natively respond to (either by returning a tile directly, by merging multiple tiles, etc.).

This setup allows MapCache to be placed transparently in front of an existing OGC-service supplying server to accelerate tiled or GetMap requests for a selected number of grids, while maintaining service compatibility for, e.g., unsupported grids, WFS requests, ...

Note

La proxyfication des requêtes se configure au sein du service WMS MapCache, ce qui peut sembler sémantiquement étrange.

La configuration de ce comportement s’active par une succession d’instructions au sein de l’élément <forwarding_rule> du <service> wms. Les règles sont testées dans l’ordre d’apparition dans le fichier mapcache.xml, et la première qui correspond est utilisée. Si aucune règle n’est indiquée, ou si aucune règle ne correspond à la requête entrante, une erreur est renvoyée à l’utilisateur.

<service type="wms" enabled="true">
   <forwarding_rule name="first rule">
      <!-- rule tests -->
      <!-- proxy destination -->
   </forwarding_rule>
   <forwarding_rule name="second rule">
      <!-- rule tests -->
      <!-- proxy destination -->
   </forwarding_rule>
</service>

Une règle de redirection (<forwarding_rule>) est faite d’un ensemble de règles de vérification et d’un bloc <http> indiquant vers où la requête doit être redirigée.

Filtrage selon des paramètres

The rules apply to the key-value pair parameters received in the incoming request, and are added with the <param> keyword:

<forwarding_rule name="first rule">
  <param name="SERVICE" type="values">WFS,WCS</param>
  <!-- ... !>
<forwarding_rule>

The “type” attribute is the same as what is allowed for dimensions, i.e. allowed values are “values”, “regex”, and “intervals”. In the previous example, the rule would match any incoming request having ...&SERVICE=WFS&... or ...&SERVICE=WCS&... in its request parameters.

<forwarding_rule name="first rule">
  <param name="SERVICE" type="values">WFS,WCS</param>
  <param name="LAYERS" type="values">somelayername</param>
  <!-- ... !>
<forwarding_rule>

Multiple rules can be used if the filtering has to be done on multiple parameters. In the previous example, the rule would match a WFS or WCS request that concerns the “somelayername” layer only.

A <forwarding_rule> that has no <param> child will match any incoming request that could not be serviced by MapCache directly from its cache, and can be used to forward all unsupported request to a full OGC- compliant server so that an un-cached response can be returned to the client.

Destination de la redirection

Une fois qu’une <forwarding_rule> correspond, son élément <http> sera utilisé pour transférer la requête à la destination indiquée.

<forwarding_rule name="first rule">
  <!-- ... !>
  <http>
     <url>http://wmsserver/ogc.cgi?</url>
  </http>
<forwarding_rule>

Voir aussi

HTTP Requests