@@ -1113,6 +1113,72 @@ If you used a non-default name for the router, you must change *_dc/router_*
1113
1113
accordingly.
1114
1114
1115
1115
1116
+ [[deploy-router-protecting-against-ddos-attacks]]
1117
+ === Protecting Against DDoS Attacks
1118
+
1119
+ Add *timeout http-request* to the default HAProxy router image to
1120
+ protect the deployment against distributed denial-of-service (DDoS) attacks (for
1121
+ example, slowloris):
1122
+
1123
+ ====
1124
+ ----
1125
+ # and the haproxy stats socket is available at /var/run/haproxy.stats
1126
+ global
1127
+ stats socket ./haproxy.stats level admin
1128
+
1129
+ defaults
1130
+ option http-server-close
1131
+ mode http
1132
+ timeout http-request 5s
1133
+ timeout connect 5s <1>
1134
+ timeout server 10s
1135
+ timeout client 30s
1136
+ ----
1137
+ <1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
1138
+ *to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
1139
+ *an error.
1140
+ ====
1141
+
1142
+ Also, when the environment variable `*ROUTER_SLOWLORIS_TIMEOUT*` is set, it
1143
+ limits the amount of time a client has to send the whole HTTP request.
1144
+ Otherwise, HAProxy will shut down the connection.
1145
+
1146
+ Setting the environment variable allows information to be captured as part
1147
+ of the router's deployment configuration and does not require manual
1148
+ modification of the template, whereas manually adding the HAProxy setting
1149
+ requires you to rebuild the router pod and maintain your router template file.
1150
+
1151
+ Using annotations implements basic DDoS protections in the HAProxy template
1152
+ router, including the ability to limit the:
1153
+
1154
+ * number of concurrent TCP connections
1155
+ * rate at which a client can request TCP connections
1156
+ * rate at which HTTP requests can be made
1157
+
1158
+ These are enabled on a per route basis because applications can have extremely
1159
+ different traffic patterns.
1160
+
1161
+ .HAProxy Template Router Settings
1162
+ [cols="2",options="header"]
1163
+ |===
1164
+
1165
+ |Setting |Description
1166
+
1167
+ |`*haproxy.router.openshift.io/rate-limit-connections*`
1168
+ |Enables the settings be configured (when set to *true*, for example).
1169
+
1170
+ |`*haproxy.router.openshift.io/rate-limit-connections.concurrent-tcp*`
1171
+ |The number of concurrent TCP connections that can be made by the same IP
1172
+ address on this route.
1173
+
1174
+ |`*haproxy.router.openshift.io/rate-limit-connections.rate-tcp*`
1175
+ |The number of TCP connections that can be opened by a client IP.
1176
+
1177
+ |`*haproxy.router.openshift.io/rate-limit-connections.rate-http*`
1178
+ |The number of HTTP requests that a client IP can make in a 3-second
1179
+ period.
1180
+ |===
1181
+
1116
1182
[[deploying-customized-router]]
1117
1183
== Deploying a Customized HAProxy Router
1118
1184
@@ -1287,8 +1353,8 @@ backend be_tcp_{{$cfgIdx}}
1287
1353
====
1288
1354
1289
1355
After this modification, you can xref:rebuilding-your-router[rebuild your router].
1290
- [[rebuilding-your-router]]
1291
1356
1357
+ [[rebuilding-your-router]]
1292
1358
=== Rebuilding Your Router
1293
1359
1294
1360
After you have made any desired modifications to the template, such as the
0 commit comments