Skip to content

Commit

Permalink
Rewrite template providing to allow custom ones
Browse files Browse the repository at this point in the history
Signed-off-by: Eloi DEMOLIS <[email protected]>
  • Loading branch information
Wonshtrum committed Dec 17, 2024
1 parent 4102871 commit 663b67f
Show file tree
Hide file tree
Showing 16 changed files with 371 additions and 479 deletions.
10 changes: 6 additions & 4 deletions bin/src/ctl/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ impl CommandManager {
},
redirect: todo!(),
redirect_scheme: todo!(),

Check warning on line 254 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

unreachable expression

Check warning on line 254 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

unreachable expression

Check warning on line 254 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

unreachable expression

Check warning on line 254 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

unreachable expression

Check warning on line 254 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

unreachable expression
redirect_template: todo!(),
rewrite_host: todo!(),
rewrite_path: todo!(),
rewrite_port: todo!(),
Expand Down Expand Up @@ -305,6 +306,7 @@ impl CommandManager {
},
redirect: todo!(),
redirect_scheme: todo!(),

Check warning on line 308 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

unreachable expression

Check warning on line 308 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

unreachable expression

Check warning on line 308 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

unreachable expression

Check warning on line 308 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

unreachable expression

Check warning on line 308 in bin/src/ctl/request_builder.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

unreachable expression
redirect_template: todo!(),
rewrite_host: todo!(),
rewrite_path: todo!(),
rewrite_port: todo!(),
Expand Down Expand Up @@ -351,8 +353,8 @@ impl CommandManager {
} => {
let https_listener = ListenerBuilder::new_https(address.into())
.with_public_address(public_address)
.with_answer_404_path(answer_404)
.with_answer_503_path(answer_503)
.with_answer("404", answer_404)
.with_answer("503", answer_503)
.with_tls_versions(tls_versions)
.with_cipher_list(cipher_list)
.with_expect_proxy(expect_proxy)
Expand Down Expand Up @@ -394,8 +396,8 @@ impl CommandManager {
} => {
let http_listener = ListenerBuilder::new_http(address.into())
.with_public_address(public_address)
.with_answer_404_path(answer_404)
.with_answer_503_path(answer_503)
.with_answer("404", answer_404)
.with_answer("503", answer_503)
.with_expect_proxy(expect_proxy)
.with_sticky_name(sticky_name)
.with_front_timeout(front_timeout)
Expand Down
4 changes: 2 additions & 2 deletions command/assets/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protocol = "http"
[[listeners]]
address = "0.0.0.0:443"
protocol = "https"
answer_404 = "./assets/custom_404.html"
answers = { "404" = "./assets/custom_404.html" }
tls_versions = ["TLS_V12"]

[[listeners]]
Expand All @@ -28,7 +28,7 @@ expect_proxy = true
[clusters]
[clusters.MyCluster]
protocol = "http"
answer_503 = "./assets/custom_503.html"
answers = { "503" = "./assets/custom_503.html" }
#sticky_session = false
#https_redirect = false
frontends = [
Expand Down
45 changes: 10 additions & 35 deletions command/src/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ message HttpListenerConfig {
required uint32 request_timeout = 10 [default = 10];
// wether the listener is actively listening on its socket
required bool active = 11 [default = false];
optional CustomHttpAnswers http_answers = 12;
map<string, string> answers = 13;
}

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

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

// custom HTTP answers, useful for 404, 503 pages
message CustomHttpAnswers {
// MovedPermanently
optional string answer_301 = 1;
// BadRequest
optional string answer_400 = 2;
// Unauthorized
optional string answer_401 = 3;
// NotFound
optional string answer_404 = 4;
// RequestTimeout
optional string answer_408 = 5;
// PayloadTooLarge
optional string answer_413 = 6;
// BadGateway
optional string answer_502 = 7;
// ServiceUnavailable
optional string answer_503 = 8;
// GatewayTimeout
optional string answer_504 = 9;
// InsufficientStorage
optional string answer_507 = 10;

}

message ActivateListener {
required SocketAddress address = 1;
required ListenerType proxy = 2;
Expand Down Expand Up @@ -239,10 +214,9 @@ message ListenersList {

enum RedirectPolicy {
FORWARD = 0;
FORCE_HTTPS = 1;
TEMPORARY = 2;
PERMANENT = 3;
UNAUTHORIZED = 4;
TEMPORARY = 1;
PERMANENT = 2;
UNAUTHORIZED = 3;
}

enum RedirectScheme {
Expand All @@ -263,9 +237,10 @@ message RequestHttpFrontend {
map<string, string> tags = 7;
optional RedirectPolicy redirect = 8;
optional RedirectScheme redirect_scheme = 9;
optional string rewrite_host = 10;
optional string rewrite_path = 11;
optional uint32 rewrite_port = 12;
optional string redirect_template = 10;
optional string rewrite_host = 11;
optional string rewrite_path = 12;
optional uint32 rewrite_port = 13;
}

message RequestTcpFrontend {
Expand Down Expand Up @@ -393,9 +368,9 @@ message Cluster {
required bool https_redirect = 3;
optional ProxyProtocolConfig proxy_protocol = 4;
required LoadBalancingAlgorithms load_balancing = 5 [default = ROUND_ROBIN];
optional string answer_503 = 6;
optional LoadMetric load_metric = 7;
optional uint32 https_redirect_port = 8;
map<string, string> answers = 9;
}

enum LoadBalancingAlgorithms {
Expand Down
Loading

0 comments on commit 663b67f

Please sign in to comment.