@@ -81,13 +81,65 @@ address = "0.0.0.0:8080"
81
81
82
82
#### Options specific to HTTP and HTTPS listeners
83
83
84
+ Since version 1.0.0, Sōzu allows custom HTTP answers defined for HTTP and HTTPS listeners.
85
+
86
+ These answers are customizable:
87
+
88
+ - 301 Moved Permanently
89
+ - 400 Bad Request
90
+ - 401 Unauthorized
91
+ - 404 Not Found
92
+ - 408 Request Timeout
93
+ - 413 Payload Too Large
94
+ - 502 Bad Gateway
95
+ - 503 Service Unavailable
96
+ - 504 Gateway Timeout
97
+ - 507 Insufficient Storage
98
+
99
+ These answers are to be provided in plain text files of whichever extension (we recommend ` .http `
100
+ for clarity) and may look like this:
101
+
102
+ ``` html
103
+ HTTP/1.1 404 Not Found
104
+ Cache-Control: no-cache
105
+ Connection: close
106
+ Sozu-Id: %REQUEST_ID
107
+
108
+ <style >pre {background :#EEE ;padding :10px ;border :1px solid #AAA ;border-radius : 5px ;} </style >
109
+ <h1 >404 Not Found</h1 >
110
+
111
+ <p >insert your custom text here, in fact, all HTML is changeable, including the CSS.</p >
112
+
113
+ <pre >
114
+ {
115
+ \"route\": \"%ROUTE\",
116
+ \"request_id\": \"%REQUEST_ID\",
117
+ }
118
+ </pre >
119
+ <footer >This is an automatic answer by Sozu.</footer >",
120
+ ```
121
+
122
+ There are a number of available template variables, like ` REQUEST_ID ` or ` CLUSTER_ID ` , that will be replaced
123
+ by the proxying logic when producing the error.
124
+
125
+ To create your own custom HTTP answers, we highly suggest you first copy the default answers present
126
+ in ` lib/src/protocol/kawa_h1/answers.rs ` , and then change them to your liking. Feel free to remove the
127
+ ` \r ` newlines of the default strings for clarity.
128
+ Sōzu will parse your file and replace whatever newline symbol(s) you use.
129
+
130
+ Then, for each listener, provide the absolute paths of each custom answer.
131
+
84
132
``` toml
85
- # path to custom 404 and 503 answers
86
133
# a 404 response is sent when sozu does not know about the requested domain or path
134
+ answer_404 = " /path/to/my-404-answer.http"
87
135
# a 503 response is sent if there are no backend servers available
88
- answer_404 = " ../lib/assets/404.html"
89
- answer_503 = " ../lib/assets/503.html"
136
+ answer_503 = " /path/to/my-503-answer.http"
137
+ # answer_507 = ...
138
+ ```
90
139
140
+ If a frontend has a ` sticky_session ` , the sticky name is defined at the listener level.
141
+
142
+ ``` toml
91
143
# defines the sticky session cookie's name, if `sticky_session` is activated format
92
144
# a cluster. Defaults to "SOZUBALANCEID"
93
145
sticky_name = " SOZUBALANCEID"
0 commit comments