blob: 539c7a5c399b7b98fd873e5dfdb9240f2c0b57b6 [file] [log] [blame]
Willy Tarreaud1142aa2007-01-07 13:03:59 +01001Prévoir des commandes en plusieurs mots clés.
2Par exemple :
3
4 timeout connection XXX
5 connection scale XXX
6
7On doit aussi accepter les préfixes :
8
9 tim co XXX
10 co sca XXX
11
12Prévoir de ranger les combinaisons dans un tableau. On doit même
13pouvoir effectuer un mapping simplifiant le parseur.
14
15
16Pour les filtres :
17
18
19 <direction> <where> <what> <operator> <pattern> <action> [ <args>* ]
20
21 <direction> = [ req | rsp ]
22 <where> = [ in | out ]
23 <what> = [ line | LINE | METH | URI | h(hdr) | H(hdr) | c(cookie) | C(cookie) ]
24 <operator> = [ == | =~ | =* | =^ | =/ | != | !~ | !* | !^ | !/ ]
25 <pattern> = "<string>"
26 <action> = [ allow | permit | deny | delete | replace | switch | add | set | redir ]
27 <args> = optionnal action args
28
29 exemples:
30
31 req in URI =^ "/images" switch images
32 req in h(host) =* ".mydomain.com" switch mydomain
33 req in h(host) =~ "localhost(.*)" replace "www\1"
34
35 alternative :
36
37 <direction> <where> <action> [not] <what> [<operator> <pattern> [ <args>* ]]
38
39 req in switch URI =^ "/images" images
40 req in switch h(host) =* ".mydomain.com" mydomain
41 req in replace h(host) =~ "localhost(.*)" "www\1"
42 req in delete h(Connection)
43 req in deny not line =~ "((GET|HEAD|POST|OPTIONS) /)|(OPTIONS *)"
44 req out set h(Connection) "close"
45 req out add line "Server: truc"
46
47
48 <direction> <action> <where> [not] <what> [<operator> <pattern> [ <args>* ]] ';' <action2> <what2>
49
50 req in switch URI =^ "/images/" images ; replace "/"
51 req in switch h(host) =* ".mydomain.com" mydomain
52 req in replace h(host) =~ "localhost(.*)" "www\1"
53 req in delete h(Connection)
54 req in deny not line =~ "((GET|HEAD|POST|OPTIONS) /)|(OPTIONS *)"
55 req out set h(Connection) "close"
56 req out add line == "Server: truc"
57
58
59Extension avec des ACL :
60
61 req in acl(meth_valid) METH =~ "(GET|POST|HEAD|OPTIONS)"
62 req in acl(meth_options) METH == "OPTIONS"
63 req in acl(uri_slash) URI =^ "/"
64 req in acl(uri_star) URI == "*"
65
66 req in deny acl !(meth_options && uri_star || meth_valid && uri_slash)
67
68Peuttre plus simplement :
69
70 acl meth_valid METH =~ "(GET|POST|HEAD|OPTIONS)"
71 acl meth_options METH == "OPTIONS"
72 acl uri_slash URI =^ "/"
73 acl uri_star URI == "*"
74
75 req in deny not acl(meth_options uri_star, meth_valid uri_slash)
76
77 req in switch URI =^ "/images/" images ; replace "/"
78 req in switch h(host) =* ".mydomain.com" mydomain
79 req in replace h(host) =~ "localhost(.*)" "www\1"
80 req in delete h(Connection)
81 req in deny not line =~ "((GET|HEAD|POST|OPTIONS) /)|(OPTIONS *)"
82 req out set h(Connection) "close"
83 req out add line == "Server: truc"
84
85Prévoir le cas du "if" pour exécuter plusieurs actions :
86
87 req in if URI =^ "/images/" then replace "/" ; switch images
88
89Utiliser les noms en majuscules/minuscules pour indiquer si on veut prendre
90en compte la casse ou non :
91
92 if uri =^ "/watch/" setbe watch rebase "/watch/" "/"
93 if uri =* ".jpg" setbe images
94 if uri =~ ".*dll.*" deny
95 if HOST =* ".mydomain.com" setbe mydomain
96 etc...
97
98Another solution would be to have a dedicated keyword to URI remapping. It
99would both rewrite the URI and optionally switch to another backend.
100
101 uriremap "/watch/" "/" watch
102 uriremap "/chat/" "/" chat
103 uriremap "/event/" "/event/" event
104
105Or better :
106
107 uriremap "/watch/" watch "/"
108 uriremap "/chat/" chat "/"
109 uriremap "/event/" event
110
111For the URI, using a regex is sometimes useful (eg: providing a set of possible prefixes.
112
113
114Sinon, peuttre que le "switch" peut prendre un paramètre de mapping pour la partie matchée :
115
116 req in switch URI =^ "/images/" images:"/"
117