Merge pull request #9152 from Schlepptop/make-nginx-proxy-http-version-configurable
Make nginx-proxy-http-version configurable per app or globally
This commit is contained in:
@@ -455,6 +455,8 @@ Changing these value globally or on a per-app basis will require rebuilding the
|
||||
| proxy-buffering | `on` | string | Enables or disables buffering of responses from the proxied server |
|
||||
| proxy-buffers | `8 8k` | string | Number and size of the buffers used for reading the proxied server response, for a single connection |
|
||||
| proxy-busy-buffers-size | `16k` | string | Limits the total size of buffers that can be busy sending a response to the client while the response is not yet fully read. |
|
||||
| proxy-http-version | `1.1` | string | The HTTP version to use for establishing a connection to your backend server. Ensure that your backend server supports this. |
|
||||
|
||||
| proxy-connect-timeout | `60s` | string | Timeout (with units) for establishing a connection to your backend server |
|
||||
| proxy-keepalive | empty (disabled) | integer | Number of idle keepalive connections to upstream servers (disabled by default) |
|
||||
| proxy-read-timeout | `60s` | string | Timeout (with units) for reading response from your backend server |
|
||||
@@ -654,6 +656,7 @@ All nginx-vhosts properties are settable at both the app and global scope.
|
||||
| `proxy-buffering` | app + global | `on` | `--nginx-proxy-buffering`, `--nginx-global-proxy-buffering`, `--nginx-computed-proxy-buffering` | Whether nginx buffers upstream responses (`on` or `off`) |
|
||||
| `proxy-buffers` | app + global | _`8 {pagesize}`_ | `--nginx-proxy-buffers`, `--nginx-global-proxy-buffers`, `--nginx-computed-proxy-buffers` | Number and size of buffers used for an upstream response |
|
||||
| `proxy-busy-buffers-size` | app + global | _`2 * pagesize`_ | `--nginx-proxy-busy-buffers-size`, `--nginx-global-proxy-busy-buffers-size`, `--nginx-computed-proxy-busy-buffers-size` | Maximum buffer size that can be busy sending a response to the client |
|
||||
| `proxy-http-version` | app + global | `1.1` | `--nginx-proxy-http-version`, `--nginx-global-proxy-http-version`, `--nginx-computed-proxy-http-version` | HTTP version to use for a connection to the upstream |
|
||||
| `proxy-connect-timeout` | app + global | `60s` | `--nginx-proxy-connect-timeout`, `--nginx-global-proxy-connect-timeout`, `--nginx-computed-proxy-connect-timeout` | Time to establish a connection to the upstream |
|
||||
| `proxy-keepalive` | app + global | none | `--nginx-proxy-keepalive`, `--nginx-global-proxy-keepalive`, `--nginx-computed-proxy-keepalive` | Number of idle keep-alive connections to upstream servers held open per worker |
|
||||
| `proxy-read-timeout` | app + global | `60s` | `--nginx-proxy-read-timeout`, `--nginx-global-proxy-read-timeout`, `--nginx-computed-proxy-read-timeout` | Time to read a response from the upstream |
|
||||
|
||||
@@ -282,6 +282,7 @@ fn-nginx-vhosts-render-template() {
|
||||
local CLIENT_MAX_BODY_SIZE="$(fn-nginx-computed-client-max-body-size "$APP")"
|
||||
local KEEPALIVE_TIMEOUT="$(fn-nginx-computed-keepalive-timeout "$APP")"
|
||||
local LINGERING_TIMEOUT="$(fn-nginx-computed-lingering-timeout "$APP")"
|
||||
local PROXY_HTTP_VERSION="$(fn-nginx-computed-proxy-http-version "$APP")"
|
||||
local PROXY_CONNECT_TIMEOUT="$(fn-nginx-computed-proxy-connect-timeout "$APP")"
|
||||
local PROXY_READ_TIMEOUT="$(fn-nginx-computed-proxy-read-timeout "$APP")"
|
||||
local PROXY_SEND_TIMEOUT="$(fn-nginx-computed-proxy-send-timeout "$APP")"
|
||||
@@ -334,6 +335,7 @@ fn-nginx-vhosts-render-template() {
|
||||
CLIENT_MAX_BODY_SIZE="$CLIENT_MAX_BODY_SIZE"
|
||||
KEEPALIVE_TIMEOUT="$KEEPALIVE_TIMEOUT"
|
||||
LINGERING_TIMEOUT="$LINGERING_TIMEOUT"
|
||||
PROXY_HTTP_VERSION="$PROXY_HTTP_VERSION"
|
||||
PROXY_CONNECT_TIMEOUT="$PROXY_CONNECT_TIMEOUT"
|
||||
PROXY_READ_TIMEOUT="$PROXY_READ_TIMEOUT"
|
||||
PROXY_SEND_TIMEOUT="$PROXY_SEND_TIMEOUT"
|
||||
|
||||
@@ -425,6 +425,27 @@ fn-nginx-global-proxy-busy-buffers-size() {
|
||||
fn-get-property --app "$APP" --global "proxy-busy-buffers-size"
|
||||
}
|
||||
|
||||
fn-nginx-proxy-http-version() {
|
||||
declare desc="get the configured proxy http version"
|
||||
declare APP="$1"
|
||||
|
||||
fn-get-property --app "$APP" "proxy-http-version"
|
||||
}
|
||||
|
||||
fn-nginx-computed-proxy-http-version() {
|
||||
declare desc="get the computed proxy http version"
|
||||
declare APP="$1"
|
||||
|
||||
fn-get-property --app "$APP" --computed "proxy-http-version"
|
||||
}
|
||||
|
||||
fn-nginx-global-proxy-http-version() {
|
||||
declare desc="get the global proxy http version"
|
||||
declare APP="$1"
|
||||
|
||||
fn-get-property --app "$APP" --global "proxy-http-version"
|
||||
}
|
||||
|
||||
fn-nginx-proxy-connect-timeout() {
|
||||
declare desc="get the configured proxy connect timeout"
|
||||
declare APP="$1"
|
||||
|
||||
@@ -436,6 +436,27 @@ func GlobalProxyBusyBuffersSize() string {
|
||||
return common.PropertyGet("nginx", "--global", "proxy-busy-buffers-size")
|
||||
}
|
||||
|
||||
func AppProxyHttpVersion(appName string) string {
|
||||
return common.PropertyGet("nginx", appName, "proxy-http-version")
|
||||
}
|
||||
|
||||
func ComputedProxyHttpVersion(appName string) string {
|
||||
appValue := AppProxyHttpVersion(appName)
|
||||
if appValue != "" {
|
||||
return appValue
|
||||
}
|
||||
|
||||
value := GlobalProxyHttpVersion()
|
||||
if value == "" {
|
||||
value = "1.1"
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func GlobalProxyHttpVersion() string {
|
||||
return common.PropertyGet("nginx", "--global", "proxy-http-version")
|
||||
}
|
||||
|
||||
func AppProxyConnectTimeout(appName string) string {
|
||||
return common.PropertyGet("nginx", appName, "proxy-connect-timeout")
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ func nginxReportProps() []nginxReportProp {
|
||||
{"proxy-buffers", AppProxyBuffers, ComputedProxyBuffers, wrapGlobal(GlobalProxyBuffers)},
|
||||
{"proxy-busy-buffers-size", AppProxyBusyBuffersSize, ComputedProxyBusyBuffersSize, wrapGlobal(GlobalProxyBusyBuffersSize)},
|
||||
{"proxy-connect-timeout", AppProxyConnectTimeout, ComputedProxyConnectTimeout, wrapGlobal(GlobalProxyConnectTimeout)},
|
||||
{"proxy-http-version", AppProxyHttpVersion, ComputedProxyHttpVersion, wrapGlobal(GlobalProxyHttpVersion)},
|
||||
{"proxy-keepalive", AppProxyKeepalive, ComputedProxyKeepalive, wrapGlobal(GlobalProxyKeepalive)},
|
||||
{"proxy-read-timeout", AppProxyReadTimeout, ComputedProxyReadTimeout, wrapGlobal(GlobalProxyReadTimeout)},
|
||||
{"proxy-send-timeout", AppProxySendTimeout, ComputedProxySendTimeout, wrapGlobal(GlobalProxySendTimeout)},
|
||||
|
||||
@@ -77,6 +77,8 @@ func appValue(appName string, property string) string {
|
||||
value = nginx_vhosts.AppProxyBuffers(appName)
|
||||
case "proxy-busy-buffers-size":
|
||||
value = nginx_vhosts.AppProxyBusyBuffersSize(appName)
|
||||
case "proxy-http-version":
|
||||
value = nginx_vhosts.AppProxyHttpVersion(appName)
|
||||
case "proxy-connect-timeout":
|
||||
value = nginx_vhosts.AppProxyConnectTimeout(appName)
|
||||
case "proxy-read-timeout":
|
||||
@@ -147,6 +149,8 @@ func computedValue(appName string, property string) string {
|
||||
value = nginx_vhosts.ComputedProxyBuffers(appName)
|
||||
case "proxy-busy-buffers-size":
|
||||
value = nginx_vhosts.ComputedProxyBusyBuffersSize(appName)
|
||||
case "proxy-http-version":
|
||||
value = nginx_vhosts.ComputedProxyHttpVersion(appName)
|
||||
case "proxy-connect-timeout":
|
||||
value = nginx_vhosts.ComputedProxyConnectTimeout(appName)
|
||||
case "proxy-read-timeout":
|
||||
@@ -217,6 +221,8 @@ func globalValue(appName string, property string) string {
|
||||
value = nginx_vhosts.GlobalProxyBuffers()
|
||||
case "proxy-busy-buffers-size":
|
||||
value = nginx_vhosts.GlobalProxyBusyBuffersSize()
|
||||
case "proxy-http-version":
|
||||
value = nginx_vhosts.GlobalProxyHttpVersion()
|
||||
case "proxy-connect-timeout":
|
||||
value = nginx_vhosts.GlobalProxyConnectTimeout()
|
||||
case "proxy-read-timeout":
|
||||
|
||||
@@ -9,13 +9,13 @@ cmd-nginx-set() {
|
||||
declare cmd="nginx:set"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1" KEY="$2" VALUE="$3"
|
||||
local VALID_KEYS=("access-log-format" "access-log-path" "bind-address-ipv4" "bind-address-ipv6" "client-body-timeout" "client-header-timeout" "client-max-body-size" "disable-custom-config" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "keepalive-timeout" "lingering-timeout" "nginx-conf-sigil-path" "nginx-service-command" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-connect-timeout" "proxy-read-timeout" "proxy-send-timeout" "proxy-keepalive" "send-timeout" "underscore-in-headers" "x-forwarded-for-value" "x-forwarded-port-value" "x-forwarded-proto-value" "x-forwarded-ssl")
|
||||
local GLOBAL_KEYS=("access-log-format" "access-log-path" "bind-address-ipv4" "bind-address-ipv6" "client-body-timeout" "client-header-timeout" "client-max-body-size" "disable-custom-config" "error-log-path" "hsts-include-subdomains" "hsts-max-age" "hsts-preload" "hsts" "keepalive-timeout" "lingering-timeout" "nginx-conf-sigil-path" "nginx-service-command" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-connect-timeout" "proxy-read-timeout" "proxy-send-timeout" "proxy-keepalive" "send-timeout" "underscore-in-headers" "x-forwarded-for-value" "x-forwarded-port-value" "x-forwarded-proto-value" "x-forwarded-ssl")
|
||||
local VALID_KEYS=("access-log-format" "access-log-path" "bind-address-ipv4" "bind-address-ipv6" "client-body-timeout" "client-header-timeout" "client-max-body-size" "disable-custom-config" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "keepalive-timeout" "lingering-timeout" "nginx-conf-sigil-path" "nginx-service-command" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-http-version" "proxy-connect-timeout" "proxy-read-timeout" "proxy-send-timeout" "proxy-keepalive" "send-timeout" "underscore-in-headers" "x-forwarded-for-value" "x-forwarded-port-value" "x-forwarded-proto-value" "x-forwarded-ssl")
|
||||
local GLOBAL_KEYS=("access-log-format" "access-log-path" "bind-address-ipv4" "bind-address-ipv6" "client-body-timeout" "client-header-timeout" "client-max-body-size" "disable-custom-config" "error-log-path" "hsts-include-subdomains" "hsts-max-age" "hsts-preload" "hsts" "keepalive-timeout" "lingering-timeout" "nginx-conf-sigil-path" "nginx-service-command" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-http-version" "proxy-connect-timeout" "proxy-read-timeout" "proxy-send-timeout" "proxy-keepalive" "send-timeout" "underscore-in-headers" "x-forwarded-for-value" "x-forwarded-port-value" "x-forwarded-proto-value" "x-forwarded-ssl")
|
||||
|
||||
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
||||
|
||||
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
||||
dokku_log_fail "Invalid key specified, valid keys include: access-log-format, access-log-path, bind-address-ipv4, bind-address-ipv6, client-body-timeout, client-header-timeout, client-max-body-size, disable-custom-config, error-log-path, hsts, hsts-include-subdomains, hsts-preload, hsts-max-age, keepalive-timeout, lingering-timeout, nginx-conf-sigil-path, nginx-service-command, proxy-buffer-size, proxy-buffering, proxy-buffers, proxy-busy-buffers-size, proxy-connect-timeout, proxy-read-timeout, proxy-send-timeout, proxy-keepalive, send-timeout, underscore-in-headers, x-forwarded-for-value, x-forwarded-port-value, x-forwarded-proto-value, x-forwarded-ssl"
|
||||
dokku_log_fail "Invalid key specified, valid keys include: access-log-format, access-log-path, bind-address-ipv4, bind-address-ipv6, client-body-timeout, client-header-timeout, client-max-body-size, disable-custom-config, error-log-path, hsts, hsts-include-subdomains, hsts-preload, hsts-max-age, keepalive-timeout, lingering-timeout, nginx-conf-sigil-path, nginx-service-command, proxy-buffer-size, proxy-buffering, proxy-buffers, proxy-busy-buffers-size, proxy-http-version, proxy-connect-timeout, proxy-read-timeout, proxy-send-timeout, proxy-keepalive, send-timeout, underscore-in-headers, x-forwarded-for-value, x-forwarded-port-value, x-forwarded-proto-value, x-forwarded-ssl"
|
||||
fi
|
||||
|
||||
if ! fn-in-array "$KEY" "${GLOBAL_KEYS[@]}" && [[ "$APP" == "--global" ]]; then
|
||||
|
||||
@@ -47,6 +47,7 @@ func defaultVars() map[string]interface{} {
|
||||
"KEEPALIVE_TIMEOUT": "75s",
|
||||
"LINGERING_TIMEOUT": "5s",
|
||||
"SEND_TIMEOUT": "60s",
|
||||
"PROXY_HTTP_VERSION": "1.1",
|
||||
"PROXY_CONNECT_TIMEOUT": "60s",
|
||||
"PROXY_READ_TIMEOUT": "60s",
|
||||
"PROXY_SEND_TIMEOUT": "60s",
|
||||
|
||||
@@ -58,7 +58,7 @@ server {
|
||||
|
||||
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
|
||||
{{ if and $is_ssl (eq $.HTTP2_PUSH_SUPPORTED "true") }}http2_push_preload on; {{ end }}
|
||||
proxy_http_version 1.1;
|
||||
proxy_http_version {{ $.PROXY_HTTP_VERSION }};
|
||||
proxy_connect_timeout {{ $.PROXY_CONNECT_TIMEOUT }};
|
||||
proxy_read_timeout {{ $.PROXY_READ_TIMEOUT }};
|
||||
proxy_send_timeout {{ $.PROXY_SEND_TIMEOUT }};
|
||||
|
||||
@@ -1044,6 +1044,10 @@ func getIngressAnnotations(appName string, processType string) (map[string]strin
|
||||
return fmt.Sprintf("proxy_busy_buffers_size %s;", value)
|
||||
},
|
||||
},
|
||||
"proxy-http-version": {
|
||||
annotation: "nginx.ingress.kubernetes.io/proxy-http-version",
|
||||
getter: nginxvhosts.ComputedProxyHttpVersion,
|
||||
},
|
||||
"proxy-connect-timeout": {
|
||||
annotation: "nginx.ingress.kubernetes.io/proxy-connect-timeout",
|
||||
getter: nginxvhosts.ComputedProxyConnectTimeout,
|
||||
|
||||
@@ -103,6 +103,7 @@ assert_nginx_property_set_get() {
|
||||
@test "(nginx:report) misc properties raw/global/computed" {
|
||||
assert_nginx_property_set_get "disable-custom-config" "false" "true"
|
||||
assert_nginx_property_set_get "underscore-in-headers" "on" "off"
|
||||
assert_nginx_property_set_get "proxy-http-version" "2" "1.1"
|
||||
assert_nginx_property_set_get "proxy-keepalive" "8" "16"
|
||||
assert_nginx_property_set_get "nginx-conf-sigil-path" "custom.sigil" "global.sigil"
|
||||
assert_nginx_property_set_get "nginx-service-command" "/usr/sbin/nginx-app" "/usr/sbin/nginx-global"
|
||||
|
||||
Reference in New Issue
Block a user