blob: d2474ce69724f69b92d5bb3dbfa38925cc0db02d [file] [log] [blame]
Willy Tarreau0ea7c432006-12-18 00:24:49 +01001There has been a lot of confusion during the development because of the
2backends and frontends.
3
4What we want :
5
6- being able to still use a listener as it has always been working
7
8- being able to write a rule stating that we will *change* the backend when we
9 match some pattern. Only one jump is allowed.
10
11- being able to write a "use_filters_from XXX" line stating that we will ignore
12 any filter in the current listener, and that those from XXX will be borrowed
13 instead. A warning would be welcome for options which will silently get
14 masked. This is used to factor configuration.
15
16- being able to write a "use_backend_from XXX" line stating that we will ignore
17 any server and timeout config in the current listener, and that those from
18 XXX will be borrowed instead. A warning would be welcome for options which
19 will silently get masked. This is used to factor configuration.
20
21
22
23Example :
24---------
25
26 | # frontend HTTP/80
27 | listen fe_http 1.1.1.1:80
28 | use_filters_from default_http
29 | use_backend_from appli1
30 |
31 | # frontend HTTPS/443
32 | listen fe_https 1.1.1.1:443
33 | use_filters_from default_https
34 | use_backend_from appli1
35 |
36 | # frontend HTTP/8080
37 | listen fe_http-dev 1.1.1.1:8080
38 | reqadd "X-proto: http"
39 | reqisetbe "^Host: www1" appli1
40 | reqisetbe "^Host: www2" appli2
41 | reqisetbe "^Host: www3" appli-dev
42 | use_backend_from appli1
43 |
44 |
45 | # filters default_http
46 | listen default_http
47 | reqadd "X-proto: http"
48 | reqisetbe "^Host: www1" appli1
49 | reqisetbe "^Host: www2" appli2
50 |
51 | # filters default_https
52 | listen default_https
53 | reqadd "X-proto: https"
54 | reqisetbe "^Host: www1" appli1
55 | reqisetbe "^Host: www2" appli2
56 |
57 |
58 | # backend appli1
59 | listen appli1
60 | reqidel "^X-appli1:.*"
61 | reqadd "Via: appli1"
62 | balance roundrobin
63 | cookie app1
64 | server srv1
65 | server srv2
66 |
67 | # backend appli2
68 | listen appli2
69 | reqidel "^X-appli2:.*"
70 | reqadd "Via: appli2"
71 | balance roundrobin
72 | cookie app2
73 | server srv1
74 | server srv2
75 |
76 | # backend appli-dev
77 | listen appli-dev
78 | reqadd "Via: appli-dev"
79 | use_backend_from appli2
80 |
81 |
82
83
84Now we clearly see multiple things :
85------------------------------------
86
87 - a frontend can EITHER have filters OR reference a use_filter
88
89 - a backend can EITHER have servers OR reference a use_backend
90
91 - we want the evaluation to cross TWO levels per request. When a request is
92 being processed, it keeps track of its "frontend" side (where it came
93 from), and of its "backend" side (where the server-side parameters have
94 been found).
95
96 - the use_{filters|backend} have nothing to do with how the request is
97 decomposed.
98
99
100Conclusion :
101------------
102
103 - a proxy is always its own frontend. It also has 2 parameters :
104 - "fi_prm" : pointer to the proxy holding the filters (itself by default)
105 - "be_prm" : pointer to the proxy holding the servers (itself by default)
106
107 - a request has a frontend (fe) and a backend (be). By default, the backend
108 is initialized to the frontend. Everything related to the client side is
109 accessed through ->fe. Everything related to the server side is accessed
110 through ->be.
111
112 - request filters are first called from ->fe then ->be. Since only the
113 filters can change ->be, it is possible to iterate the filters on ->be
114 only and stop when ->be does not change anymore.
115
116 - response filters are first called from ->be then ->fe IF (fe != be).
117
118
119When we parse the configuration, we immediately configure ->fi and ->be for
120all proxies.
121
122Upon session creation, s->fe and s->be are initialized to the proxy. Filters
123are executed via s->fe->fi_prm and s->be->fi_prm. Servers are found in
124s->be->be_prm.
125