Skip to content

Commit 6701c49

Browse files
committed
Rewrite template providing to allow custom ones
Signed-off-by: Eloi DEMOLIS <[email protected]>
1 parent 4102871 commit 6701c49

File tree

13 files changed

+357
-459
lines changed

13 files changed

+357
-459
lines changed

bin/src/ctl/request_builder.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ impl CommandManager {
252252
},
253253
redirect: todo!(),
254254
redirect_scheme: todo!(),
255+
redirect_template: todo!(),
255256
rewrite_host: todo!(),
256257
rewrite_path: todo!(),
257258
rewrite_port: todo!(),
@@ -305,6 +306,7 @@ impl CommandManager {
305306
},
306307
redirect: todo!(),
307308
redirect_scheme: todo!(),
309+
redirect_template: todo!(),
308310
rewrite_host: todo!(),
309311
rewrite_path: todo!(),
310312
rewrite_port: todo!(),
@@ -351,8 +353,8 @@ impl CommandManager {
351353
} => {
352354
let https_listener = ListenerBuilder::new_https(address.into())
353355
.with_public_address(public_address)
354-
.with_answer_404_path(answer_404)
355-
.with_answer_503_path(answer_503)
356+
.with_answer("404", answer_404)
357+
.with_answer("503", answer_503)
356358
.with_tls_versions(tls_versions)
357359
.with_cipher_list(cipher_list)
358360
.with_expect_proxy(expect_proxy)
@@ -394,8 +396,8 @@ impl CommandManager {
394396
} => {
395397
let http_listener = ListenerBuilder::new_http(address.into())
396398
.with_public_address(public_address)
397-
.with_answer_404_path(answer_404)
398-
.with_answer_503_path(answer_503)
399+
.with_answer("404", answer_404)
400+
.with_answer("503", answer_503)
399401
.with_expect_proxy(expect_proxy)
400402
.with_sticky_name(sticky_name)
401403
.with_front_timeout(front_timeout)

command/src/command.proto

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ message HttpListenerConfig {
129129
required uint32 request_timeout = 10 [default = 10];
130130
// wether the listener is actively listening on its socket
131131
required bool active = 11 [default = false];
132-
optional CustomHttpAnswers http_answers = 12;
132+
map<string, string> answers = 13;
133133
}
134134

135135
// details of an HTTPS listener
@@ -161,7 +161,7 @@ message HttpsListenerConfig {
161161
// The tickets allow the client to resume a session. This protects the client
162162
// agains session tracking. Defaults to 4.
163163
required uint64 send_tls13_tickets = 20;
164-
optional CustomHttpAnswers http_answers = 21;
164+
map<string, string> answers = 22;
165165
}
166166

167167
// details of an TCP listener
@@ -179,31 +179,6 @@ message TcpListenerConfig {
179179
required bool active = 7 [default = false];
180180
}
181181

182-
// custom HTTP answers, useful for 404, 503 pages
183-
message CustomHttpAnswers {
184-
// MovedPermanently
185-
optional string answer_301 = 1;
186-
// BadRequest
187-
optional string answer_400 = 2;
188-
// Unauthorized
189-
optional string answer_401 = 3;
190-
// NotFound
191-
optional string answer_404 = 4;
192-
// RequestTimeout
193-
optional string answer_408 = 5;
194-
// PayloadTooLarge
195-
optional string answer_413 = 6;
196-
// BadGateway
197-
optional string answer_502 = 7;
198-
// ServiceUnavailable
199-
optional string answer_503 = 8;
200-
// GatewayTimeout
201-
optional string answer_504 = 9;
202-
// InsufficientStorage
203-
optional string answer_507 = 10;
204-
205-
}
206-
207182
message ActivateListener {
208183
required SocketAddress address = 1;
209184
required ListenerType proxy = 2;
@@ -239,10 +214,9 @@ message ListenersList {
239214

240215
enum RedirectPolicy {
241216
FORWARD = 0;
242-
FORCE_HTTPS = 1;
243-
TEMPORARY = 2;
244-
PERMANENT = 3;
245-
UNAUTHORIZED = 4;
217+
TEMPORARY = 1;
218+
PERMANENT = 2;
219+
UNAUTHORIZED = 3;
246220
}
247221

248222
enum RedirectScheme {
@@ -263,9 +237,10 @@ message RequestHttpFrontend {
263237
map<string, string> tags = 7;
264238
optional RedirectPolicy redirect = 8;
265239
optional RedirectScheme redirect_scheme = 9;
266-
optional string rewrite_host = 10;
267-
optional string rewrite_path = 11;
268-
optional uint32 rewrite_port = 12;
240+
optional string redirect_template = 10;
241+
optional string rewrite_host = 11;
242+
optional string rewrite_path = 12;
243+
optional uint32 rewrite_port = 13;
269244
}
270245

271246
message RequestTcpFrontend {
@@ -393,9 +368,9 @@ message Cluster {
393368
required bool https_redirect = 3;
394369
optional ProxyProtocolConfig proxy_protocol = 4;
395370
required LoadBalancingAlgorithms load_balancing = 5 [default = ROUND_ROBIN];
396-
optional string answer_503 = 6;
397371
optional LoadMetric load_metric = 7;
398372
optional uint32 https_redirect_port = 8;
373+
map<string, string> answers = 9;
399374
}
400375

401376
enum LoadBalancingAlgorithms {

0 commit comments

Comments
 (0)