Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add limit-request-status-code option #2001

Merged
merged 3 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/user-guide/configmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ The following table shows a configuration option's name, type, and the default v
|[limit‑rate‑after](#limit-rate-after)|int|0|
|[http‑redirect‑code](#http-redirect-code)|int|308|
|[proxy‑buffering](#proxy-buffering)|string|"off"|
|[limit‑request‑status‑code](#limit-request-status-code)|int|503|

## add-headers

Expand Down Expand Up @@ -702,4 +703,8 @@ Why the default code is 308?

## proxy-buffering

Enables or disables [buffering of responses from the proxied server](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering).
Enables or disables [buffering of responses from the proxied server](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering).

## limit-request-status-code

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
6 changes: 6 additions & 0 deletions internal/ingress/controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ type Configuration struct {
// server to the client response
// Default: empty
HideHeaders []string `json:"hide-headers"`

// LimitReqStatusCode 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
LimitReqStatusCode int `json:"limit-req-status-code"`
}

// NewDefault returns the default nginx configuration
Expand Down Expand Up @@ -560,6 +565,7 @@ func NewDefault() Configuration {
JaegerServiceName: "nginx",
JaegerSamplerType: "const",
JaegerSamplerParam: "1",
LimitReqStatusCode: 503,
}

if glog.V(5) {
Expand Down
2 changes: 2 additions & 0 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ http {
underscores_in_headers {{ if $cfg.EnableUnderscoresInHeaders }}on{{ else }}off{{ end }};
ignore_invalid_headers {{ if $cfg.IgnoreInvalidHeaders }}on{{ else }}off{{ end }};

limit_req_status {{ $cfg.LimitReqStatusCode }};

{{ if $cfg.EnableOpentracing }}
opentracing on;
{{ end }}
Expand Down