Jump to content

User:YuviPanda/Dynamicproxy URL routing

From Wikitech

The dynamicproxy puppet module supports a url based proxying mode, that can be enabled by setting luahandler => 'urlproxy.lua'

Redis format

You can add routes to it by directly modifying entries in Redis. For security reasons redis should not be reachable over the network, and you should run a local deamon on the proxy machine to write rules to Redis.

The routing is based on a 'prefix'. It refers to the first part of the URL path that is being requested. For a URL such as /toolname/test1, the prefix is /toolname. You would have an entry in Redis with the prefix as the key and the value being a hashtable that contains the routes for that particular prefix.

For example, assume we want the following routing:

  1. /toolname/phpthing -> tools-exec-05:3313
  2. /toolname/gothing -> tools-exec-03:3198
  3. /toolname/nodething -> tools-exec-01:5532

The redis structure for this routing would be:

Key: '/toolname'

Value: Redis HashTable, with the following entries:

  1. /phpthing.* -> http://tools-exec-05:3313
  2. /gothing.* -> http://tools-exec-03:3198
  3. /nodething.* -> http://tools-exec-01:5532

Notes:

  1. the prefix needs to be a plain string that starts with a /.
  2. The individual routes in the hashtable have keys that are PCREs.
  3. The protocol reference in the value in the hashtable is required.