From f2465c369e4fbabd963c44a5c6d33e1c7e1d5f55 Mon Sep 17 00:00:00 2001
From: Rich Bowen
- # Comment line
+ # Comment line
MatchingKey SubstValue
MatchingKey SubstValue # comment
MapType: rnd
, MapSource: Unix filesystem
- path to valid regular file
This is identical to the Standard Plain Text variant
- above but with a special post-processing feature: After
- looking up a value it is parsed according to contained
- ``|
'' characters which have the meaning of
- ``or''. In other words they indicate a set of
- alternatives from which the actual returned value is
- chosen randomly. For example, you might use the following map
- file and directives to provide a random load balancing between
- several back-end server, via a reverse-proxy. Images are sent
- to one of the servers in the 'static' pool, while everything
- else is sent to one of the 'dynamic' pool.
Example:
+ +When a MapType of rnd
is used, the MapSource is a
+ filesystem path to a plain-text mapping file, each line of which
+ contains a key, and one or more values separated by |
.
+ One of these values will be chosen at random if the key is
+ matched.
For example, you might use the following map + file and directives to provide a random load balancing between + several back-end server, via a reverse-proxy. Images are sent + to one of the servers in the 'static' pool, while everything + else is sent to one of the 'dynamic' pool.
+## ## map.txt -- rewriting map @@ -196,13 +195,29 @@ telephone 328 static www1|www2|www3|www4 dynamic www5|www6
-RewriteMap servers rnd:/path/to/file/map.txt
-
-RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1
-[NC,P,L]
-RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]
-
So, when an image is requested and the first of these rules is
+ matched, RewriteMap
looks up the string
+ static
in the map file, which returns one of the
+ specified hostnames at random, which is then used in the
+ RewriteRule
target.
If you wanted to have one of the servers more likely to be chosen + (for example, if one of the server has more memory than the others, + and so can handle more requests) simply list it more times in the + map file.
+ +
+static www1|www1|www2|www3|www4
+
- # Comment line
+ # Comment line
MatchingKey SubstValue
MatchingKey SubstValue # comment
MapType: rnd
, MapSource: Unix filesystem
- path to valid regular file
This is identical to the Standard Plain Text variant
- above but with a special post-processing feature: After
- looking up a value it is parsed according to contained
- ``|
'' characters which have the meaning of
- ``or''. In other words they indicate a set of
- alternatives from which the actual returned value is
- chosen randomly. For example, you might use the following map
- file and directives to provide a random load balancing between
- several back-end server, via a reverse-proxy. Images are sent
- to one of the servers in the 'static' pool, while everything
- else is sent to one of the 'dynamic' pool.
Example:
-When a MapType of rnd
is used, the MapSource is a
+ filesystem path to a plain-text mapping file, each line of which
+ contains a key, and one or more values separated by |
.
+ One of these values will be chosen at random if the key is
+ matched.
For example, you might use the following map + file and directives to provide a random load balancing between + several back-end server, via a reverse-proxy. Images are sent + to one of the servers in the 'static' pool, while everything + else is sent to one of the 'dynamic' pool.
+ +## ## map.txt -- rewriting map @@ -199,14 +197,31 @@ static www1|www2|www3|www4 dynamic www5|www6
So, when an image is requested and the first of these rules is
+ matched, RewriteMap
looks up the string
+ static
in the map file, which returns one of the
+ specified hostnames at random, which is then used in the
+ RewriteRule
target.
If you wanted to have one of the servers more likely to be chosen + (for example, if one of the server has more memory than the others, + and so can handle more requests) simply list it more times in the + map file.
+ +MapType: -- cgit v1.2.3