| 1 | # Don't allow more than 10 active concurrent connections from the same host. |
|---|
| 2 | throttle.max-concurrent-connections = 10 |
|---|
| 3 | |
|---|
| 4 | # Don't allow more than three fcgi requests at once. |
|---|
| 5 | $HTTP["url"] =~ "/dispatch.fcgi" { |
|---|
| 6 | throttle.max-concurrent-connections = 3 |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | # Don't allow more than one /expensive.xml request at once. Since this |
|---|
| 10 | # is a (fictional) Rails request that will be 404 redirected, use orig-url. |
|---|
| 11 | $HTTP["orig-url"] =~ "/rails/expensive.xml" { |
|---|
| 12 | throttle.max-concurrent-connections = 1 |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | # Limit connections for /big-files/. |
|---|
| 16 | $HTTP["url"] =~ "^/big-files/" { |
|---|
| 17 | throttle.max-concurrent-connections = 3 |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | $HTTP["url"] =~ "^/small-files/" { |
|---|
| 21 | # Allow 4 requests to be made per second, with bursts of up |
|---|
| 22 | # to 20 requests in a second. |
|---|
| 23 | throttle.bucket-size = 20 |
|---|
| 24 | throttle.tokens-per-second = 4 |
|---|
| 25 | |
|---|
| 26 | } |
|---|
| 27 | # HACK: prevent lighttpd from merging config sections |
|---|
| 28 | $HTTP["url"] =~ "/dispatch.fcgi|^ba29b12f" { |
|---|
| 29 | # Allow 1 connection/sec over 5 minutes |
|---|
| 30 | throttle.bucket-size = 300 |
|---|
| 31 | throttle.tokens-per-second = 1 |
|---|
| 32 | |
|---|
| 33 | # If the token bucket empties, ban the user for an hour. |
|---|
| 34 | throttle.ban-when-empty = 1 |
|---|
| 35 | throttle.ban-duration = 3600 |
|---|
| 36 | } |
|---|