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:
@@ -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 }};
|
||||
|
||||
Reference in New Issue
Block a user