feat: add support for various timeout-related functions to nginx, openresty and k3s plugins

Closes #7267
This commit is contained in:
Jose Diaz-Gonzalez
2024-10-16 00:43:35 -04:00
parent 07149fb846
commit 4d7f779c28
13 changed files with 475 additions and 14 deletions

View File

@@ -49,6 +49,12 @@ cmd-nginx-report-single() {
"--nginx-bind-address-ipv6: $(fn-nginx-bind-address-ipv6 "$APP")"
"--nginx-computed-bind-address-ipv6: $(fn-nginx-computed-bind-address-ipv6 "$APP")"
"--nginx-global-bind-address-ipv6: $(fn-nginx-global-bind-address-ipv6 "$APP")"
"--nginx-client-body-timeout: $(fn-nginx-client-body-timeout "$APP")"
"--nginx-computed-client-body-timeout: $(fn-nginx-computed-client-body-timeout "$APP")"
"--nginx-global-client-body-timeout: $(fn-nginx-global-client-body-timeout "$APP")"
"--nginx-client-header-timeout: $(fn-nginx-client-header-timeout "$APP")"
"--nginx-computed-client-header-timeout: $(fn-nginx-computed-client-header-timeout "$APP")"
"--nginx-global-client-header-timeout: $(fn-nginx-global-client-header-timeout "$APP")"
"--nginx-client-max-body-size: $(fn-nginx-client-max-body-size "$APP")"
"--nginx-computed-client-max-body-size: $(fn-nginx-computed-client-max-body-size "$APP")"
"--nginx-global-client-max-body-size: $(fn-nginx-global-client-max-body-size "$APP")"
@@ -71,6 +77,12 @@ cmd-nginx-report-single() {
"--nginx-computed-hsts: $(fn-nginx-computed-hsts "$APP")"
"--nginx-global-hsts: $(fn-nginx-global-hsts "$APP")"
"--nginx-last-visited-at: $(fn-nginx-vhosts-last-visited-at "$APP")"
"--nginx-keepalive-timeout: $(fn-nginx-keepalive-timeout "$APP")"
"--nginx-computed-keepalive-timeout: $(fn-nginx-computed-keepalive-timeout "$APP")"
"--nginx-global-keepalive-timeout: $(fn-nginx-global-keepalive-timeout "$APP")"
"--nginx-lingering-timeout: $(fn-nginx-lingering-timeout "$APP")"
"--nginx-computed-lingering-timeout: $(fn-nginx-computed-lingering-timeout "$APP")"
"--nginx-global-lingering-timeout: $(fn-nginx-global-lingering-timeout "$APP")"
"--nginx-nginx-conf-sigil-path: $(fn-nginx-nginx-conf-sigil-path "$APP")"
"--nginx-computed-nginx-conf-sigil-path: $(fn-nginx-computed-nginx-conf-sigil-path "$APP")"
"--nginx-global-nginx-conf-sigil-path: $(fn-nginx-global-nginx-conf-sigil-path "$APP")"
@@ -86,9 +98,18 @@ cmd-nginx-report-single() {
"--nginx-proxy-busy-buffers-size: $(fn-nginx-proxy-busy-buffers-size "$APP")"
"--nginx-computed-proxy-busy-buffers-size: $(fn-nginx-computed-proxy-busy-buffers-size "$APP")"
"--nginx-global-proxy-busy-buffers-size: $(fn-nginx-global-proxy-busy-buffers-size "$APP")"
"--nginx-proxy-connect-timeout: $(fn-nginx-proxy-connect-timeout "$APP")"
"--nginx-computed-proxy-connect-timeout: $(fn-nginx-computed-proxy-connect-timeout "$APP")"
"--nginx-global-proxy-connect-timeout: $(fn-nginx-global-proxy-connect-timeout "$APP")"
"--nginx-proxy-read-timeout: $(fn-nginx-proxy-read-timeout "$APP")"
"--nginx-computed-proxy-read-timeout: $(fn-nginx-computed-proxy-read-timeout "$APP")"
"--nginx-global-proxy-read-timeout: $(fn-nginx-global-proxy-read-timeout "$APP")"
"--nginx-proxy-send-timeout: $(fn-nginx-proxy-send-timeout "$APP")"
"--nginx-computed-proxy-send-timeout: $(fn-nginx-computed-proxy-send-timeout "$APP")"
"--nginx-global-proxy-send-timeout: $(fn-nginx-global-proxy-send-timeout "$APP")"
"--nginx-send-timeout: $(fn-nginx-send-timeout "$APP")"
"--nginx-computed-send-timeout: $(fn-nginx-computed-send-timeout "$APP")"
"--nginx-global-send-timeout: $(fn-nginx-global-send-timeout "$APP")"
"--nginx-underscore-in-headers: $(fn-nginx-underscore-in-headers "$APP")"
"--nginx-computed-underscore-in-headers: $(fn-nginx-computed-underscore-in-headers "$APP")"
"--nginx-global-underscore-in-headers: $(fn-nginx-global-underscore-in-headers "$APP")"

View File

@@ -310,8 +310,15 @@ nginx_build_config() {
local NGINX_ACCESS_LOG_FORMAT="$(fn-nginx-computed-access-log-format "$APP")"
local NGINX_ACCESS_LOG_PATH="$(fn-nginx-computed-access-log-path "$APP")"
local NGINX_ERROR_LOG_PATH="$(fn-nginx-computed-error-log-path "$APP")"
local CLIENT_BODY_TIMEOUT="$(fn-nginx-computed-client-body-timeout "$APP")"
local CLIENT_HEADER_TIMEOUT="$(fn-nginx-computed-client-header-timeout "$APP")"
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_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")"
local SEND_TIMEOUT="$(fn-nginx-computed-send-timeout "$APP")"
local PROXY_BUFFER_SIZE="$(fn-nginx-computed-proxy-buffer-size "$APP")"
local PROXY_BUFFERING="$(fn-nginx-computed-proxy-buffering "$APP")"
local PROXY_BUFFERS="$(fn-nginx-computed-proxy-buffers "$APP")"
@@ -368,8 +375,15 @@ nginx_build_config() {
GRPC_SUPPORTED="$GRPC_SUPPORTED"
DOKKU_APP_LISTEN_PORT="$DOKKU_APP_LISTEN_PORT" DOKKU_APP_LISTEN_IP="$DOKKU_APP_LISTEN_IP"
APP_SSL_PATH="$APP_SSL_PATH" SSL_INUSE="$SSL_INUSE" SSL_SERVER_NAME="$SSL_SERVER_NAME"
CLIENT_BODY_TIMEOUT="$CLIENT_BODY_TIMEOUT"
CLIENT_HEADER_TIMEOUT="$CLIENT_HEADER_TIMEOUT"
CLIENT_MAX_BODY_SIZE="$CLIENT_MAX_BODY_SIZE"
KEEPALIVE_TIMEOUT="$KEEPALIVE_TIMEOUT"
LINGERING_TIMEOUT="$LINGERING_TIMEOUT"
PROXY_CONNECT_TIMEOUT="$PROXY_CONNECT_TIMEOUT"
PROXY_READ_TIMEOUT="$PROXY_READ_TIMEOUT"
PROXY_SEND_TIMEOUT="$PROXY_SEND_TIMEOUT"
SEND_TIMEOUT="$SEND_TIMEOUT"
PROXY_BUFFER_SIZE="$PROXY_BUFFER_SIZE"
PROXY_BUFFERING="$PROXY_BUFFERING"
PROXY_BUFFERS="$PROXY_BUFFERS"

View File

@@ -88,6 +88,48 @@ fn-nginx-global-bind-address-ipv6() {
fn-get-property --app "$APP" --global "bind-address-ipv6"
}
fn-nginx-client-body-timeout() {
declare desc="get the configured client body timeout"
declare APP="$1"
fn-get-property --app "$APP" "client-body-timeout"
}
fn-nginx-computed-client-body-timeout() {
declare desc="get the computed client body timeout"
declare APP="$1"
fn-get-property --app "$APP" --computed "client-body-timeout"
}
fn-nginx-global-client-body-timeout() {
declare desc="get the global client body timeout"
declare APP="$1"
fn-get-property --app "$APP" --global "client-body-timeout"
}
fn-nginx-client-header-timeout() {
declare desc="get the configured client header timeout"
declare APP="$1"
fn-get-property --app "$APP" "client-header-timeout"
}
fn-nginx-computed-client-header-timeout() {
declare desc="get the computed client header timeout"
declare APP="$1"
fn-get-property --app "$APP" --computed "client-header-timeout"
}
fn-nginx-global-client-header-timeout() {
declare desc="get the global client header timeout"
declare APP="$1"
fn-get-property --app "$APP" --global "client-header-timeout"
}
fn-nginx-client-max-body-size() {
declare desc="get the configured client max body size"
declare APP="$1"
@@ -228,6 +270,48 @@ fn-nginx-log-root() {
echo "$NGINX_LOG_ROOT"
}
fn-nginx-keepalive-timeout() {
declare desc="get the configured keepalive timeout"
declare APP="$1"
fn-get-property --app "$APP" "keepalive-timeout"
}
fn-nginx-computed-keepalive-timeout() {
declare desc="get the computed keepalive timeout"
declare APP="$1"
fn-get-property --app "$APP" --computed "keepalive-timeout"
}
fn-nginx-global-keepalive-timeout() {
declare desc="get the global keepalive timeout"
declare APP="$1"
fn-get-property --app "$APP" --global "keepalive-timeout"
}
fn-nginx-lingering-timeout() {
declare desc="get the configured lingering timeout"
declare APP="$1"
fn-get-property --app "$APP" "lingering-timeout"
}
fn-nginx-computed-lingering-timeout() {
declare desc="get the computed lingering timeout"
declare APP="$1"
fn-get-property --app "$APP" --computed "lingering-timeout"
}
fn-nginx-global-lingering-timeout() {
declare desc="get the global lingering timeout"
declare APP="$1"
fn-get-property --app "$APP" --global "lingering-timeout"
}
fn-nginx-nginx-conf-sigil-path() {
declare APP="$1"
fn-get-property --app "$APP" "nginx-conf-sigil-path"
@@ -326,6 +410,27 @@ fn-nginx-global-proxy-busy-buffers-size() {
fn-get-property --app "$APP" --global "proxy-busy-buffers-size"
}
fn-nginx-proxy-connect-timeout() {
declare desc="get the configured proxy connect timeout"
declare APP="$1"
fn-get-property --app "$APP" "proxy-connect-timeout"
}
fn-nginx-computed-proxy-connect-timeout() {
declare desc="get the computed proxy connect timeout"
declare APP="$1"
fn-get-property --app "$APP" --computed "proxy-connect-timeout"
}
fn-nginx-global-proxy-connect-timeout() {
declare desc="get the global proxy connect timeout"
declare APP="$1"
fn-get-property --app "$APP" --global "proxy-connect-timeout"
}
fn-nginx-proxy-read-timeout() {
declare desc="get the configured proxy read timeout"
declare APP="$1"
@@ -347,6 +452,48 @@ fn-nginx-global-proxy-read-timeout() {
fn-get-property --app "$APP" --global "proxy-read-timeout"
}
fn-nginx-proxy-send-timeout() {
declare desc="get the configured proxy send timeout"
declare APP="$1"
fn-get-property --app "$APP" "proxy-send-timeout"
}
fn-nginx-computed-proxy-send-timeout() {
declare desc="get the computed proxy send timeout"
declare APP="$1"
fn-get-property --app "$APP" --computed "proxy-send-timeout"
}
fn-nginx-global-proxy-send-timeout() {
declare desc="get the global proxy send timeout"
declare APP="$1"
fn-get-property --app "$APP" --global "proxy-send-timeout"
}
fn-nginx-send-timeout() {
declare desc="get the configured send timeout"
declare APP="$1"
fn-get-property --app "$APP" "send-timeout"
}
fn-nginx-computed-send-timeout() {
declare desc="get the computed send timeout"
declare APP="$1"
fn-get-property --app "$APP" --computed "send-timeout"
}
fn-nginx-global-send-timeout() {
declare desc="get the global send timeout"
declare APP="$1"
fn-get-property --app "$APP" --global "send-timeout"
}
fn-nginx-underscore-in-headers() {
declare desc="get the configured underscore in headers value"
declare APP="$1"

View File

@@ -76,6 +76,40 @@ func GlobalBindAddressIPv6() string {
return common.PropertyGetDefault("nginx", "--global", "bind-address-ipv6", "::")
}
func AppClientBodyTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "client-body-timeout")
}
func ComputedClientBodyTimeout(appName string) string {
appValue := AppClientBodyTimeout(appName)
if appValue != "" {
return appValue
}
return GlobalClientBodyTimeout()
}
func GlobalClientBodyTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "client-body-timeout", "60s")
}
func AppClientHeaderTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "client-header-timeout")
}
func ComputedClientHeaderTimeout(appName string) string {
appValue := AppClientHeaderTimeout(appName)
if appValue != "" {
return appValue
}
return GlobalClientHeaderTimeout()
}
func GlobalClientHeaderTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "client-header-timeout", "60s")
}
func AppClientMaxBodySize(appName string) string {
return common.PropertyGet("nginx", appName, "client-max-body-size")
}
@@ -200,6 +234,40 @@ func AppNginxConfSigilPath(appName string) string {
return common.PropertyGet("nginx", appName, "nginx-conf-sigil-path")
}
func AppKeepaliveTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "keepalive-timeout")
}
func ComputedKeepaliveTimeout(appName string) string {
appValue := AppKeepaliveTimeout(appName)
if appValue != "" {
return appValue
}
return GlobalKeepaliveTimeout()
}
func GlobalKeepaliveTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "keepalive-timeout", "75s")
}
func AppLingeringTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "lingering-timeout")
}
func ComputedLingeringTimeout(appName string) string {
appValue := AppLingeringTimeout(appName)
if appValue != "" {
return appValue
}
return GlobalLingeringTimeout()
}
func GlobalLingeringTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "lingering-timeout", "5s")
}
func ComputedNginxConfSigilPath(appName string) string {
appValue := AppNginxConfSigilPath(appName)
if appValue != "" {
@@ -281,6 +349,23 @@ func GlobalProxyBusyBuffersSize() string {
return common.PropertyGetDefault("nginx", "--global", "proxy-busy-buffers-size", fmt.Sprintf("%dk", (os.Getpagesize()/1024)*2))
}
func AppProxyConnectTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "proxy-connect-timeout")
}
func ComputedProxyConnectTimeout(appName string) string {
appValue := AppProxyConnectTimeout(appName)
if appValue != "" {
return appValue
}
return GlobalProxyConnectTimeout()
}
func GlobalProxyConnectTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "proxy-connect-timeout", "60s")
}
func AppProxyReadTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "proxy-read-timeout")
}
@@ -298,6 +383,40 @@ func GlobalProxyReadTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "proxy-read-timeout", "60s")
}
func AppProxySendTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "proxy-send-timeout")
}
func ComputedProxySendTimeout(appName string) string {
appValue := AppProxySendTimeout(appName)
if appValue != "" {
return appValue
}
return GlobalProxySendTimeout()
}
func GlobalProxySendTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "proxy-send-timeout", "60s")
}
func AppSendTimeout(appName string) string {
return common.PropertyGet("nginx", appName, "send-timeout")
}
func ComputedSendTimeout(appName string) string {
appValue := AppSendTimeout(appName)
if appValue != "" {
return appValue
}
return GlobalSendTimeout()
}
func GlobalSendTimeout() string {
return common.PropertyGetDefault("nginx", "--global", "send-timeout", "60s")
}
func AppUnderscoreInHeaders(appName string) string {
return common.PropertyGet("nginx", appName, "underscore-in-headers")
}

View File

@@ -45,6 +45,10 @@ func appValue(appName string, property string) string {
value = nginx_vhosts.AppBindAddressIPv6(appName)
case "client-max-body-size":
value = nginx_vhosts.AppClientMaxBodySize(appName)
case "client-body-timeout":
value = nginx_vhosts.AppClientBodyTimeout(appName)
case "client-header-timeout":
value = nginx_vhosts.AppClientHeaderTimeout(appName)
case "disable-custom-config":
value = nginx_vhosts.AppDisableCustomConfig(appName)
case "error-log-path":
@@ -57,6 +61,10 @@ func appValue(appName string, property string) string {
value = nginx_vhosts.AppHSTSPreload(appName)
case "hsts":
value = nginx_vhosts.AppHSTS(appName)
case "keepalive-timeout":
value = nginx_vhosts.AppKeepaliveTimeout(appName)
case "lingering-timeout":
value = nginx_vhosts.AppLingeringTimeout(appName)
case "nginx-conf-sigil-path":
value = nginx_vhosts.AppNginxConfSigilPath(appName)
case "proxy-buffer-size":
@@ -67,8 +75,14 @@ func appValue(appName string, property string) string {
value = nginx_vhosts.AppProxyBuffers(appName)
case "proxy-busy-buffers-size":
value = nginx_vhosts.AppProxyBusyBuffersSize(appName)
case "proxy-connect-timeout":
value = nginx_vhosts.AppProxyConnectTimeout(appName)
case "proxy-read-timeout":
value = nginx_vhosts.AppProxyReadTimeout(appName)
case "proxy-send-timeout":
value = nginx_vhosts.AppProxySendTimeout(appName)
case "send-timeout":
value = nginx_vhosts.AppSendTimeout(appName)
case "underscore-in-headers":
value = nginx_vhosts.AppUnderscoreInHeaders(appName)
case "x-forwarded-for-value":
@@ -95,6 +109,10 @@ func computedValue(appName string, property string) string {
value = nginx_vhosts.ComputedBindAddressIPv4(appName)
case "bind-address-ipv6":
value = nginx_vhosts.ComputedBindAddressIPv6(appName)
case "client-body-timeout":
value = nginx_vhosts.ComputedClientBodyTimeout(appName)
case "client-header-timeout":
value = nginx_vhosts.ComputedClientHeaderTimeout(appName)
case "client-max-body-size":
value = nginx_vhosts.ComputedClientMaxBodySize(appName)
case "disable-custom-config":
@@ -109,6 +127,10 @@ func computedValue(appName string, property string) string {
value = nginx_vhosts.ComputedHSTSPreload(appName)
case "hsts":
value = nginx_vhosts.ComputedHSTS(appName)
case "keepalive-timeout":
value = nginx_vhosts.ComputedKeepaliveTimeout(appName)
case "lingering-timeout":
value = nginx_vhosts.ComputedLingeringTimeout(appName)
case "nginx-conf-sigil-path":
value = nginx_vhosts.ComputedNginxConfSigilPath(appName)
case "proxy-buffer-size":
@@ -119,8 +141,14 @@ func computedValue(appName string, property string) string {
value = nginx_vhosts.ComputedProxyBuffers(appName)
case "proxy-busy-buffers-size":
value = nginx_vhosts.ComputedProxyBusyBuffersSize(appName)
case "proxy-connect-timeout":
value = nginx_vhosts.ComputedProxyConnectTimeout(appName)
case "proxy-read-timeout":
value = nginx_vhosts.ComputedProxyReadTimeout(appName)
case "proxy-send-timeout":
value = nginx_vhosts.ComputedProxySendTimeout(appName)
case "send-timeout":
value = nginx_vhosts.ComputedSendTimeout(appName)
case "underscore-in-headers":
value = nginx_vhosts.ComputedUnderscoreInHeaders(appName)
case "x-forwarded-for-value":
@@ -147,6 +175,10 @@ func globalValue(appName string, property string) string {
value = nginx_vhosts.GlobalBindAddressIPv4()
case "bind-address-ipv6":
value = nginx_vhosts.GlobalBindAddressIPv6()
case "client-body-timeout":
value = nginx_vhosts.ComputedClientBodyTimeout(appName)
case "client-header-timeout":
value = nginx_vhosts.ComputedClientHeaderTimeout(appName)
case "client-max-body-size":
value = nginx_vhosts.GlobalClientMaxBodySize()
case "disable-custom-config":
@@ -161,6 +193,10 @@ func globalValue(appName string, property string) string {
value = nginx_vhosts.GlobalHSTSPreload()
case "hsts":
value = nginx_vhosts.GlobalHSTS()
case "keepalive-timeout":
value = nginx_vhosts.ComputedKeepaliveTimeout(appName)
case "lingering-timeout":
value = nginx_vhosts.ComputedLingeringTimeout(appName)
case "nginx-conf-sigil-path":
value = nginx_vhosts.GlobalNginxConfSigilPath()
case "proxy-buffer-size":
@@ -171,8 +207,14 @@ func globalValue(appName string, property string) string {
value = nginx_vhosts.GlobalProxyBuffers()
case "proxy-busy-buffers-size":
value = nginx_vhosts.GlobalProxyBusyBuffersSize()
case "proxy-connect-timeout":
value = nginx_vhosts.GlobalProxyConnectTimeout()
case "proxy-read-timeout":
value = nginx_vhosts.GlobalProxyReadTimeout()
case "proxy-send-timeout":
value = nginx_vhosts.GlobalProxySendTimeout()
case "send-timeout":
value = nginx_vhosts.GlobalSendTimeout()
case "underscore-in-headers":
value = nginx_vhosts.GlobalUnderscoreInHeaders()
case "x-forwarded-for-value":

View File

@@ -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-max-body-size" "disable-custom-config" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "nginx-conf-sigil-path" "proxy-read-timeout" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "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-max-body-size" "disable-custom-config" "error-log-path" "hsts-include-subdomains" "hsts-max-age" "hsts-preload" "hsts" "nginx-conf-sigil-path" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-read-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" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-connect-timeout" "proxy-read-timeout" "proxy-send-timeout" "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" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-connect-timeout" "proxy-read-timeout" "proxy-send-timeout" "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-max-body-size, disable-custom-config, error-log-path, hsts, hsts-include-subdomains, hsts-preload, hsts-max-age, nginx-conf-sigil-path, proxy-read-timeout, proxy-buffer-size, proxy-buffering, proxy-buffers, proxy-busy-buffers-size, 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, proxy-buffer-size, proxy-buffering, proxy-buffers, proxy-busy-buffers-size, proxy-connect-timeout, proxy-read-timeout, proxy-send-timeout, 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[@]}"; then

View File

@@ -12,6 +12,13 @@ server {
access_log {{ $.NGINX_ACCESS_LOG_PATH }}{{ if and ($.NGINX_ACCESS_LOG_FORMAT) (ne $.NGINX_ACCESS_LOG_PATH "off") }} {{ $.NGINX_ACCESS_LOG_FORMAT }}{{ end }};
error_log {{ $.NGINX_ERROR_LOG_PATH }};
underscores_in_headers {{ $.NGINX_UNDERSCORE_IN_HEADERS }};
client_body_timeout {{ $.CLIENT_BODY_TIMEOUT }};
client_header_timeout {{ $.CLIENT_HEADER_TIMEOUT }};
keepalive_timeout {{ $.KEEPALIVE_TIMEOUT }};
lingering_timeout {{ $.LINGERING_TIMEOUT }};
send_timeout {{ $.SEND_TIMEOUT }};
{{ if (and (eq $listen_port "80") ($.SSL_INUSE)) }}
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
location / {
@@ -29,7 +36,9 @@ server {
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
proxy_http_version 1.1;
proxy_connect_timeout {{ $.PROXY_CONNECT_TIMEOUT }};
proxy_read_timeout {{ $.PROXY_READ_TIMEOUT }};
proxy_send_timeout {{ $.PROXY_SEND_TIMEOUT }};
proxy_buffer_size {{ $.PROXY_BUFFER_SIZE }};
proxy_buffering {{ $.PROXY_BUFFERING }};
proxy_buffers {{ $.PROXY_BUFFERS }};
@@ -81,7 +90,11 @@ server {
ssl_protocols TLSv1.2 {{ if eq $.TLS13_SUPPORTED "true" }}TLSv1.3{{ end }};
ssl_prefer_server_ciphers off;
keepalive_timeout 70;
client_body_timeout {{ $.CLIENT_BODY_TIMEOUT }};
client_header_timeout {{ $.CLIENT_HEADER_TIMEOUT }};
keepalive_timeout {{ $.KEEPALIVE_TIMEOUT }};
lingering_timeout {{ $.LINGERING_TIMEOUT }};
send_timeout {{ $.SEND_TIMEOUT }};
location / {
@@ -95,7 +108,9 @@ server {
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
{{ if eq $.HTTP2_PUSH_SUPPORTED "true" }}http2_push_preload on; {{ end }}
proxy_http_version 1.1;
proxy_connect_timeout {{ $.PROXY_CONNECT_TIMEOUT }};
proxy_read_timeout {{ $.PROXY_READ_TIMEOUT }};
proxy_send_timeout {{ $.PROXY_SEND_TIMEOUT }};
proxy_buffer_size {{ $.PROXY_BUFFER_SIZE }};
proxy_buffering {{ $.PROXY_BUFFERING }};
proxy_buffers {{ $.PROXY_BUFFERS }};

View File

@@ -40,6 +40,8 @@ cmd-openresty-report-single() {
"--openresty-allowed-letsencrypt-domains-func-base64: $(fn-openresty-allowed-letsencrypt-domains-func-base64)"
"--openresty-bind-address-ipv4: $(fn-openresty-bind-address-ipv4 "$APP")"
"--openresty-bind-address-ipv6: $(fn-openresty-bind-address-ipv6 "$APP")"
"--openresty-client-body-timeout: $(fn-openresty-client-body-timeout "$APP")"
"--openresty-client-header-timeout: $(fn-openresty-client-header-timeout "$APP")"
"--openresty-client-max-body-size: $(fn-openresty-client-max-body-size "$APP")"
"--openresty-error-log-path: $(fn-openresty-error-log-path "$APP")"
"--openresty-global-hsts: $(fn-plugin-property-get-default "openresty" "--global" "hsts" "true")"
@@ -49,13 +51,18 @@ cmd-openresty-report-single() {
"--openresty-hsts-max-age: $(fn-openresty-hsts-max-age "$APP")"
"--openresty-hsts-preload: $(fn-openresty-hsts-preload "$APP")"
"--openresty-image: $(fn-openresty-image)"
"--openresty-keepalive-timeout: $(fn-openresty-keepalive-timeout "$APP")"
"--openresty-letsencrypt-email: $(fn-openresty-letsencrypt-email)"
"--openresty-letsencrypt-server: $(fn-openresty-letsencrypt-server)"
"--openresty-lingering-timeout: $(fn-openresty-lingering-timeout "$APP")"
"--openresty-proxy-buffer-size: $(fn-openresty-proxy-buffer-size "$APP")"
"--openresty-proxy-buffering: $(fn-openresty-proxy-buffering "$APP")"
"--openresty-proxy-buffers: $(fn-openresty-proxy-buffers "$APP")"
"--openresty-proxy-busy-buffers-size: $(fn-openresty-proxy-busy-buffers-size "$APP")"
"--openresty-proxy-connect-timeout: $(fn-openresty-proxy-connect-timeout "$APP")"
"--openresty-proxy-read-timeout: $(fn-openresty-proxy-read-timeout "$APP")"
"--openresty-proxy-send-timeout: $(fn-openresty-proxy-send-timeout "$APP")"
"--openresty-send-timeout: $(fn-openresty-send-timeout "$APP")"
"--openresty-underscore-in-headers: $(fn-openresty-underscore-in-headers "$APP")"
"--openresty-x-forwarded-for-value: $(fn-openresty-x-forwarded-for-value "$APP")"
"--openresty-x-forwarded-port-value: $(fn-openresty-x-forwarded-port-value "$APP")"

View File

@@ -124,6 +124,10 @@ trigger-openresty-vhosts-docker-args-process-deploy() {
[[ -n "$value" ]] && output="$output '--label=openresty.bind-address-ipv4=$value'"
value="$(fn-openresty-bind-address-ipv6 "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.bind-address-ipv6=$value'"
value="$(fn-openresty-client-body-timeout "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.client-body-timeout=$value'"
value="$(fn-openresty-client-header-timeout "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.client-header-timeout=$value'"
value="$(fn-openresty-client-max-body-size "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.client-max-body-size=$value'"
value="$(fn-openresty-error-log-path "$APP")"
@@ -142,6 +146,10 @@ trigger-openresty-vhosts-docker-args-process-deploy() {
[[ -n "$value" ]] && output="$output '--label=openresty.domains=$value'"
value="$(plugn trigger network-get-property "$APP" initial-network)"
[[ -n "$value" ]] && output="$output '--label=openresty.initial-network=$value'"
value="$(fn-openresty-keepalive-timeout "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.keepalive-timeout=$value'"
value="$(fn-openresty-lingering-timeout "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.lingering-timeout=$value'"
value="$(echo "$APP_PORT_MAP" | xargs)"
[[ -n "$value" ]] && output="$output '--label=openresty.port-mapping=$value'"
value="$(fn-openresty-proxy-buffer-size "$APP")"
@@ -160,6 +168,8 @@ trigger-openresty-vhosts-docker-args-process-deploy() {
[[ -n "$value" ]] && output="$output '--label=openresty.proxy-send-timeout=$value'"
value="$(fn-openresty-send-timeout "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.send-timeout=$value'"
value="$(fn-openresty-send-timeout "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.send-timeout=$value'"
value="$(fn-openresty-underscore-in-headers "$APP")"
[[ -n "$value" ]] && output="$output '--label=openresty.underscore-in-headers=$value'"
value="$(fn-openresty-x-forwarded-for-value "$APP")"

View File

@@ -46,6 +46,20 @@ fn-openresty-bind-address-ipv6() {
fn-plugin-property-get-default "openresty" "$APP" "bind-address-ipv6" "::"
}
fn-openresty-client-body-timeout() {
declare desc="get the configured client body timeout"
declare APP="$1"
fn-plugin-property-get-default "openresty" "$APP" "client-body-timeout" "60s"
}
fn-openresty-client-header-timeout() {
declare desc="get the configured client header timeout"
declare APP="$1"
fn-plugin-property-get-default "openresty" "$APP" "client-body-timeout" "60s"
}
fn-openresty-client-max-body-size() {
declare desc="get the configured client max body size"
declare APP="$1"
@@ -121,6 +135,13 @@ fn-openresty-image() {
fn-plugin-property-get-default "openresty" "--global" "image" "$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/Dockerfile" | awk '{print $2}')"
}
fn-openresty-keepalive-timeout() {
declare desc="get the configured keepalive timeout"
declare APP="$1"
fn-plugin-property-get-default "openresty" "$APP" "keepalive-timeout" "75s"
}
fn-openresty-letsencrypt-email() {
fn-plugin-property-get-default "openresty" "--global" "letsencrypt-email" ""
}
@@ -156,6 +177,13 @@ fn-openresty-logs-usage() {
echo " -t, --tail # continually stream logs"
}
fn-openresty-lingering-timeout() {
declare desc="get the configured lingering timeout"
declare APP="$1"
fn-plugin-property-get-default "openresty" "$APP" "lingering-timeout" "5s"
}
fn-openresty-proxy-buffer-size() {
declare desc="get the configured proxy buffer size"
declare APP="$1"
@@ -206,7 +234,7 @@ fn-openresty-proxy-send-timeout() {
}
fn-openresty-send-timeout() {
declare desc="get the configured proxy send timeout"
declare desc="get the configured send timeout"
declare APP="$1"
fn-plugin-property-get-default "openresty" "$APP" "send-timeout" "60s"

View File

@@ -9,13 +9,13 @@ cmd-openresty-set() {
declare cmd="openresty:set"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=("access-log-format" "access-log-path" "allowed-letsencrypt-domains-func-base64" "bind-address-ipv4" "bind-address-ipv6" "client-max-body-size" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "image" "log-level" "letsencrypt-email" "letsencrypt-server" "proxy-read-timeout" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "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" "allowed-letsencrypt-domains-func-base64" "bind-address-ipv4" "bind-address-ipv6" "client-body-timeout" "client-header-timeout" "client-max-body-size" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "image" "keepalive-timeout" "log-level" "letsencrypt-email" "letsencrypt-server" "lingering-timeout" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size" "proxy-connect-timeout" "proxy-read-timeout" "send-timeout" "proxy-send-timeout" "underscore-in-headers" "x-forwarded-for-value" "x-forwarded-port-value" "x-forwarded-proto-value" "x-forwarded-ssl")
local GLOBAL_KEYS=("allowed-letsencrypt-domains-func-base64" "image" "log-level" "letsencrypt-email" "letsencrypt-server")
[[ -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, allowed-letsencrypt-domains-func-base64, bind-address-ipv4, bind-address-ipv6, client-max-body-size, error-log-path, hsts, hsts-include-subdomains, hsts-preload, hsts-max-age, image, log-level, letsencrypt-email, letsencrypt-server, proxy-read-timeout, proxy-buffer-size, proxy-buffering, proxy-buffers, proxy-busy-buffers-size, 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, allowed-letsencrypt-domains-func-base64, bind-address-ipv4, bind-address-ipv6, client-body-timeout, client-header-timeout, client-max-body-size, error-log-path, hsts, hsts-include-subdomains, hsts-preload, hsts-max-age, image, keepalive-timeout, log-level, letsencrypt-email, letsencrypt-server, lingering-timeout, proxy-connect-timeout, proxy-connect-timeout, proxy-read-timeout, proxy-send-timeout, 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[@]}"; then

View File

@@ -806,6 +806,24 @@ func getIngressAnnotations(appName string, processType string) (map[string]strin
"bind-address-ipv6": {
getter: nginxvhosts.ComputedBindAddressIPv6,
},
"client-body-timeout": {
getter: nginxvhosts.ComputedClientBodyTimeout,
serverSnippet: func(value string) string {
if value == "" {
return ""
}
return fmt.Sprintf("client_body_timeout %s;", value)
},
},
"client-header-timeout": {
getter: nginxvhosts.ComputedClientHeaderTimeout,
serverSnippet: func(value string) string {
if value == "" {
return ""
}
return fmt.Sprintf("client_header_timeout %s;", value)
},
},
"client-max-body-size": {
annotation: "nginx.ingress.kubernetes.io/proxy-body-size",
getter: nginxvhosts.ComputedClientMaxBodySize,
@@ -835,6 +853,24 @@ func getIngressAnnotations(appName string, processType string) (map[string]strin
"hsts": {
getter: nginxvhosts.ComputedHSTS,
},
"keepalive-timeout": {
getter: nginxvhosts.ComputedKeepaliveTimeout,
serverSnippet: func(value string) string {
if value == "" {
return ""
}
return fmt.Sprintf("keepalive_timeout %s;", value)
},
},
"lingering-timeout": {
getter: nginxvhosts.ComputedLingeringTimeout,
serverSnippet: func(value string) string {
if value == "" {
return ""
}
return fmt.Sprintf("lingering_timeout %s;", value)
},
},
"nginx-conf-sigil-path": {
getter: nginxvhosts.ComputedNginxConfSigilPath,
},
@@ -859,10 +895,27 @@ func getIngressAnnotations(appName string, processType string) (map[string]strin
return fmt.Sprintf("proxy_busy_buffers_size %s;", value)
},
},
"proxy-connect-timeout": {
annotation: "nginx.ingress.kubernetes.io/proxy-connect-timeout",
getter: nginxvhosts.ComputedProxyConnectTimeout,
},
"proxy-read-timeout": {
annotation: "nginx.ingress.kubernetes.io/proxy-read-timeout",
getter: nginxvhosts.ComputedProxyReadTimeout,
},
"proxy-send-timeout": {
annotation: "nginx.ingress.kubernetes.io/proxy-send-timeout",
getter: nginxvhosts.ComputedProxySendTimeout,
},
"send-timeout": {
getter: nginxvhosts.ComputedSendTimeout,
serverSnippet: func(value string) string {
if value == "" {
return ""
}
return fmt.Sprintf("send_timeout %s;", value)
},
},
"underscore-in-headers": {
getter: nginxvhosts.ComputedUnderscoreInHeaders,
serverSnippet: func(value string) string {