Skip to content

Commit 4caaef7

Browse files
committed
feat(router): Adding large_client_header_buffers annotations to hephy-router
1 parent 018b675 commit 4caaef7

5 files changed

Lines changed: 31 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ _Note that Kubernetes annotation maps are all of Go type `map[string]string`. A
239239
| <a name="gzip-types"></a>deis-router | deployment | [router.deis.io/nginx.gzip.types](#gzip-types) | `"application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component"` | nginx `gzip_types` setting. |
240240
| <a name="gzip-vary"></a>deis-router | deployment | [router.deis.io/nginx.gzip.vary](#gzip-vary) | `"on"` | nginx `gzip_vary` setting. |
241241
| <a name="body-size"></a>deis-router | deployment | [router.deis.io/nginx.bodySize](#body-size) | `"1m"`| nginx `client_max_body_size` setting expressed in bytes (no suffix), kilobytes (suffixes `k` and `K`), or megabytes (suffixes `m` and `M`). |
242+
| <a name="large-client-header-buffers-count"></a>deis-router | deployment | [router.deis.io/nginx.largeHeaderBuffersCount](#large-client-header-buffers-count) | `"4"`| nginx `large_client_header_buffers` number setting. Sets the maximum number of buffers used for reading large client request header. |
243+
| <a name="large-client-header-buffers-size"></a>deis-router | deployment | [router.deis.io/nginx.largeHeaderBuffersSize](#large-client-header-buffers-size) | `"32k"`| nginx `large_client_header_buffers` size expressed in bytes (no suffix), kilobytes (suffixes `k` and `K`), or megabytes (suffixes `m` and `M`). Sets the maximum size of the buffers used for reading large client request header. |
242244
| <a name="proxy-real-ip-cidrs"></a>deis-router | deployment | [router.deis.io/nginx.proxyRealIpCidrs](#proxy-real-ip-cidrs) | `"10.0.0.0/8"` | Comma-delimited list of IP/CIDRs that define trusted addresses that are known to send correct replacement addresses. These map to multiple nginx `set_real_ip_from` directives. |
243245
| <a name="error-log-level"></a>deis-router | deployment | [router.deis.io/nginx.errorLogLevel](#error-log-level) | `"error"` | Log level used in the nginx `error_log` setting (valid values are: `debug`, `info`, `notice`, `warn`, `error`, `crit`, `alert`, and `emerg`). |
244246
| <a name="platform-domain"></a>deis-router | deployment | [router.deis.io/nginx.platformDomain](#platform-domain) | N/A | This defines the router's platform domain. Any domains added to a routable application _not_ containing the `.` character will be assumed to be subdomains of this platform domain. Thus, for example, a platform domain of `example.com` coupled with a routable app counting `foo` among its domains will result in router configuration that routes traffic for `foo.example.com` to that application. |

model/model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ type RouterConfig struct {
4646
ServerNameHashBucketSize string `key:"serverNameHashBucketSize" constraint:"^[1-9]\\d*[kKmM]?$"`
4747
GzipConfig *GzipConfig `key:"gzip"`
4848
BodySize string `key:"bodySize" constraint:"^[0-9]\\d*[kKmM]?$"`
49+
LargeHeaderBuffersCount string `key:"largeHeaderBuffersCount" constraint:"^[1-9]\\d*$"`
50+
LargeHeaderBuffersSize string `key:"largeHeaderBuffersSize" constraint:"^[0-9]\\d*[kKmM]?$"`
4951
ProxyRealIPCIDRs []string `key:"proxyRealIpCidrs" constraint:"^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/([0-9]|[1-2][0-9]|3[0-2]))?(\\s*,\\s*)?)+$"`
5052
ErrorLogLevel string `key:"errorLogLevel" constraint:"^(debug|info|notice|warn|error|crit|alert|emerg)$"`
5153
PlatformDomain string `key:"platformDomain" constraint:"(?i)^([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z0-9]+(-*[a-z0-9]+)+$"`
@@ -81,6 +83,8 @@ func newRouterConfig() (*RouterConfig, error) {
8183
ServerNameHashBucketSize: "64",
8284
GzipConfig: newGzipConfig(),
8385
BodySize: "1m",
86+
LargeHeaderBuffersCount: "4",
87+
LargeHeaderBuffersSize: "32k",
8488
ProxyRealIPCIDRs: []string{"10.0.0.0/8"},
8589
DisableServerTokens: false,
8690
ErrorLogLevel: "error",

model/model_validation_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ func TestValidBodySize(t *testing.T) {
7171
testValidValues(t, newTestRouterConfig, "BodySize", "bodySize", []string{"1", "2", "20", "1k", "2k", "10m", "10M"})
7272
}
7373

74+
func TestInvalidLargeHeaderBuffersCount(t *testing.T) {
75+
testInvalidValues(t, newTestRouterConfig, "LargeHeaderBuffersCount", "largeHeaderBuffersCount", []string{"0", "-1", "foobar"})
76+
}
77+
78+
func TestValidLargeHeaderBuffersCount(t *testing.T) {
79+
testValidValues(t, newTestRouterConfig, "LargeHeaderBuffersCount", "largeHeaderBuffersCount", []string{"1", "2", "4", "8", "16", "32"})
80+
}
81+
82+
func TestInvalidLargeHeaderBuffersSize(t *testing.T) {
83+
testInvalidValues(t, newTestRouterConfig, "LargeHeaderBuffersSize", "largeHeaderBuffersSize", []string{"-1", "foobar"})
84+
}
85+
86+
func TestValidLargeHeaderBuffersSize(t *testing.T) {
87+
testValidValues(t, newTestRouterConfig, "LargeHeaderBuffersSize", "largeHeaderBuffersSize", []string{"1", "2", "20", "1k", "2k", "10m", "10M"})
88+
}
89+
7490
func TestInvalidProxyRealIPCIDRs(t *testing.T) {
7591
testInvalidValues(t, newTestRouterConfig, "ProxyRealIPCIDRs", "proxyRealIpCidrs", []string{"0", "-1", "foobar"})
7692
}

nginx/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ http {
4747
gzip_vary {{ $gzipConfig.Vary }};{{ end }}
4848
4949
client_max_body_size {{ $routerConfig.BodySize }};
50+
large_client_header_buffers {{ $routerConfig.LargeHeaderBuffersCount }} {{ $routerConfig.LargeHeaderBuffersSize }};
5051
5152
{{ if $routerConfig.DisableServerTokens -}}
5253
server_tokens off;

nginx/config_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,14 @@ func TestDisableServerTokens(t *testing.T) {
241241
Types: "application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component",
242242
Vary: "on",
243243
},
244-
BodySize: "1m",
245-
ProxyRealIPCIDRs: []string{"10.0.0.0/8"},
246-
ErrorLogLevel: "error",
247-
UseProxyProtocol: false,
248-
EnforceWhitelists: false,
249-
WhitelistMode: "extend",
244+
BodySize: "1m",
245+
LargeHeaderBuffersCount: "4",
246+
LargeHeaderBuffersSize: "32k",
247+
ProxyRealIPCIDRs: []string{"10.0.0.0/8"},
248+
ErrorLogLevel: "error",
249+
UseProxyProtocol: false,
250+
EnforceWhitelists: false,
251+
WhitelistMode: "extend",
250252
SSLConfig: &model.SSLConfig{
251253
Enforce: false,
252254
Protocols: "TLSv1 TLSv1.1 TLSv1.2",

0 commit comments

Comments
 (0)