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-connect-timeout() {
|
||||
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-connect-timeout")
|
||||
}
|
||||
|
||||
func AppProxyConnectTimeout(appName string) string {
|
||||
return common.PropertyGet("nginx", appName, "proxy-connect-timeout")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,43 +22,44 @@ func templatePath(t *testing.T) string {
|
||||
|
||||
func defaultVars() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"APP": "app",
|
||||
"DOKKU_ROOT": "/home/dokku",
|
||||
"DOKKU_LIB_ROOT": "/var/lib/dokku",
|
||||
"NOSSL_SERVER_NAME": "app.example.com",
|
||||
"SSL_SERVER_NAME": "",
|
||||
"SSL_INUSE": "",
|
||||
"APP_SSL_PATH": "/home/dokku/app/tls",
|
||||
"DOKKU_APP_WEB_LISTENERS": "127.0.0.1:5000",
|
||||
"PROXY_PORT_MAP": "http:80:5000",
|
||||
"PROXY_UPSTREAM_PORTS": "5000",
|
||||
"PROXY_PORT": "80",
|
||||
"PROXY_SSL_PORT": "443",
|
||||
"PROXY_KEEPALIVE": "",
|
||||
"NGINX_BIND_ADDRESS_IP4": "",
|
||||
"NGINX_BIND_ADDRESS_IP6": "::",
|
||||
"NGINX_ACCESS_LOG_PATH": "/var/log/nginx/app-access.log",
|
||||
"NGINX_ACCESS_LOG_FORMAT": "",
|
||||
"NGINX_ERROR_LOG_PATH": "/var/log/nginx/app-error.log",
|
||||
"NGINX_UNDERSCORE_IN_HEADERS": "off",
|
||||
"CLIENT_BODY_TIMEOUT": "60s",
|
||||
"CLIENT_HEADER_TIMEOUT": "60s",
|
||||
"CLIENT_MAX_BODY_SIZE": "1m",
|
||||
"KEEPALIVE_TIMEOUT": "75s",
|
||||
"LINGERING_TIMEOUT": "5s",
|
||||
"SEND_TIMEOUT": "60s",
|
||||
"PROXY_CONNECT_TIMEOUT": "60s",
|
||||
"PROXY_READ_TIMEOUT": "60s",
|
||||
"PROXY_SEND_TIMEOUT": "60s",
|
||||
"PROXY_BUFFER_SIZE": "4k",
|
||||
"PROXY_BUFFERING": "on",
|
||||
"PROXY_BUFFERS": "8 4k",
|
||||
"PROXY_BUSY_BUFFERS_SIZE": "8k",
|
||||
"PROXY_X_FORWARDED_FOR": "$remote_addr",
|
||||
"PROXY_X_FORWARDED_PORT": "$server_port",
|
||||
"PROXY_X_FORWARDED_PROTO": "$scheme",
|
||||
"PROXY_X_FORWARDED_SSL": "",
|
||||
"HTTP2_DIRECTIVE_SUPPORTED": "true",
|
||||
"APP": "app",
|
||||
"DOKKU_ROOT": "/home/dokku",
|
||||
"DOKKU_LIB_ROOT": "/var/lib/dokku",
|
||||
"NOSSL_SERVER_NAME": "app.example.com",
|
||||
"SSL_SERVER_NAME": "",
|
||||
"SSL_INUSE": "",
|
||||
"APP_SSL_PATH": "/home/dokku/app/tls",
|
||||
"DOKKU_APP_WEB_LISTENERS": "127.0.0.1:5000",
|
||||
"PROXY_PORT_MAP": "http:80:5000",
|
||||
"PROXY_UPSTREAM_PORTS": "5000",
|
||||
"PROXY_PORT": "80",
|
||||
"PROXY_SSL_PORT": "443",
|
||||
"PROXY_KEEPALIVE": "",
|
||||
"NGINX_BIND_ADDRESS_IP4": "",
|
||||
"NGINX_BIND_ADDRESS_IP6": "::",
|
||||
"NGINX_ACCESS_LOG_PATH": "/var/log/nginx/app-access.log",
|
||||
"NGINX_ACCESS_LOG_FORMAT": "",
|
||||
"NGINX_ERROR_LOG_PATH": "/var/log/nginx/app-error.log",
|
||||
"NGINX_UNDERSCORE_IN_HEADERS": "off",
|
||||
"CLIENT_BODY_TIMEOUT": "60s",
|
||||
"CLIENT_HEADER_TIMEOUT": "60s",
|
||||
"CLIENT_MAX_BODY_SIZE": "1m",
|
||||
"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",
|
||||
"PROXY_BUFFER_SIZE": "4k",
|
||||
"PROXY_BUFFERING": "on",
|
||||
"PROXY_BUFFERS": "8 4k",
|
||||
"PROXY_BUSY_BUFFERS_SIZE": "8k",
|
||||
"PROXY_X_FORWARDED_FOR": "$remote_addr",
|
||||
"PROXY_X_FORWARDED_PORT": "$server_port",
|
||||
"PROXY_X_FORWARDED_PROTO": "$scheme",
|
||||
"PROXY_X_FORWARDED_SSL": "",
|
||||
"HTTP2_DIRECTIVE_SUPPORTED": "true",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,8 +267,8 @@ func TestTemplate_XForwardedSSL(t *testing.T) {
|
||||
|
||||
func TestTemplate_NginxConfDIncludeAlways(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
mutate func(map[string]interface{})
|
||||
name string
|
||||
mutate func(map[string]interface{})
|
||||
}{
|
||||
{"http", func(v map[string]interface{}) {}},
|
||||
{"http_redirect", func(v map[string]interface{}) {
|
||||
|
||||
@@ -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