Skip to content

Commit 2f700a9

Browse files
aramasealedbf
authored andcommitted
Add limit-request-status-code option (#2001)
* Add support for limit_req_status * Add documentation * Fix comment
1 parent 951a704 commit 2f700a9

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

docs/user-guide/configmap.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ The following table shows a configuration option's name, type, and the default v
127127
|[limit‑rate‑after](#limit-rate-after)|int|0|
128128
|[http‑redirect‑code](#http-redirect-code)|int|308|
129129
|[proxy‑buffering](#proxy-buffering)|string|"off"|
130+
|[limit‑request‑status‑code](#limit-request-status-code)|int|503|
130131

131132
## add-headers
132133

@@ -702,4 +703,8 @@ Why the default code is 308?
702703

703704
## proxy-buffering
704705

705-
Enables or disables [buffering of responses from the proxied server](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering).
706+
Enables or disables [buffering of responses from the proxied server](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering).
707+
708+
## limit-request-status-code
709+
710+
Sets the [status code to return in response to rejected requests](http://nginx.org/en/docs/http/ngx_http_limit_req_module.html#limit_req_status).Default: 503

internal/ingress/controller/config/config.go

+6
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ type Configuration struct {
467467
// server to the client response
468468
// Default: empty
469469
HideHeaders []string `json:"hide-headers"`
470+
471+
// LimitReqStatusCode Sets the status code to return in response to rejected requests.
472+
// http://nginx.org/en/docs/http/ngx_http_limit_req_module.html#limit_req_status
473+
// Default: 503
474+
LimitReqStatusCode int `json:"limit-req-status-code"`
470475
}
471476

472477
// NewDefault returns the default nginx configuration
@@ -560,6 +565,7 @@ func NewDefault() Configuration {
560565
JaegerServiceName: "nginx",
561566
JaegerSamplerType: "const",
562567
JaegerSamplerParam: "1",
568+
LimitReqStatusCode: 503,
563569
}
564570

565571
if glog.V(5) {

rootfs/etc/nginx/template/nginx.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ http {
102102
underscores_in_headers {{ if $cfg.EnableUnderscoresInHeaders }}on{{ else }}off{{ end }};
103103
ignore_invalid_headers {{ if $cfg.IgnoreInvalidHeaders }}on{{ else }}off{{ end }};
104104

105+
limit_req_status {{ $cfg.LimitReqStatusCode }};
106+
105107
{{ if $cfg.EnableOpentracing }}
106108
opentracing on;
107109
{{ end }}

0 commit comments

Comments
 (0)