refactor: consolidate property fetching for nginx plugin into golang codebase
Also update the documentation to include docs for all properties.
This commit is contained in:
1 parent
6625846ecc
commit
d4b445985b
14 files changed
+1448
-492
No files matched your search
+17
-133
@@ -6,120 +6,6 @@ source "$PLUGIN_AVAILABLE_PATH/certs/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||
|
||||
fn-nginx-log-root() {
|
||||
declare desc="get the nginx log root"
|
||||
local NGINX_LOG_ROOT="/var/log/nginx"
|
||||
fn-nginx-vhosts-uses-openresty && NGINX_LOG_ROOT="/var/log/openresty"
|
||||
echo "$NGINX_LOG_ROOT"
|
||||
}
|
||||
|
||||
fn-nginx-access-log-format() {
|
||||
declare desc="get the configured access log format"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "access-log-format" ""
|
||||
}
|
||||
|
||||
fn-nginx-access-log-path() {
|
||||
declare desc="get the configured access log path"
|
||||
declare APP="$1"
|
||||
local NGINX_LOG_ROOT="$(fn-nginx-log-root)"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "access-log-path" "${NGINX_LOG_ROOT}/${APP}-access.log"
|
||||
}
|
||||
|
||||
fn-nginx-bind-address-ipv4() {
|
||||
declare desc="get the configured ipv4 bind address"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "bind-address-ipv4" ""
|
||||
}
|
||||
|
||||
fn-nginx-bind-address-ipv6() {
|
||||
declare desc="get the configured ipv6 bind address"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "bind-address-ipv6" "::"
|
||||
}
|
||||
|
||||
fn-nginx-proxy-buffer-size() {
|
||||
declare desc="get the configured proxy buffer size"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "proxy-buffer-size" "$(fn-get-pagesize)"
|
||||
}
|
||||
|
||||
fn-nginx-proxy-buffering() {
|
||||
declare desc="get the configured proxy buffering"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "proxy-buffering" "on"
|
||||
}
|
||||
|
||||
fn-nginx-proxy-buffers() {
|
||||
declare desc="get the configured proxy buffers"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "proxy-buffers" "8 $(fn-get-pagesize)"
|
||||
}
|
||||
|
||||
fn-nginx-proxy-busy-buffers-size() {
|
||||
declare desc="get the configured proxy busy buffers size"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "proxy-busy-buffers-size" "$(($(fn-get-pagesize) * 2))"
|
||||
}
|
||||
|
||||
fn-nginx-proxy-read-timeout() {
|
||||
declare desc="get the configured proxy read timeout"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "proxy-read-timeout" "60s"
|
||||
}
|
||||
|
||||
fn-nginx-client-max-body-size() {
|
||||
declare desc="get the configured client max body size"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "client-max-body-size" ""
|
||||
}
|
||||
|
||||
fn-nginx-error-log-path() {
|
||||
declare desc="get the configured access log path"
|
||||
declare APP="$1"
|
||||
local NGINX_LOG_ROOT="$(fn-nginx-log-root)"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "error-log-path" "${NGINX_LOG_ROOT}/${APP}-error.log"
|
||||
}
|
||||
|
||||
fn-nginx-x-forwarded-for-value() {
|
||||
declare desc="get the configured x-forwarded-for value"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "x-forwarded-for-value" "\$remote_addr"
|
||||
}
|
||||
|
||||
fn-nginx-x-forwarded-port-value() {
|
||||
declare desc="get the configured x-forwarded-port value"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "x-forwarded-port-value" "\$server_port"
|
||||
}
|
||||
|
||||
fn-nginx-x-forwarded-proto-value() {
|
||||
declare desc="get the configured x-forwarded-proto value"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "x-forwarded-proto-value" "\$scheme"
|
||||
}
|
||||
|
||||
fn-nginx-x-forwarded-ssl() {
|
||||
declare desc="get the configured x-forwarded-ssl value"
|
||||
declare APP="$1"
|
||||
|
||||
fn-plugin-property-get-default "nginx" "$APP" "x-forwarded-ssl" ""
|
||||
}
|
||||
|
||||
get_nginx_location() {
|
||||
declare desc="check that nginx is at the expected location and return it"
|
||||
fn-nginx-vhosts-nginx-location
|
||||
@@ -182,7 +68,7 @@ nginx_logs() {
|
||||
declare NGINX_LOGS_TYPE="${1#nginx:}" APP="$2"
|
||||
|
||||
local NGINX_LOGS_TYPE=${NGINX_LOGS_TYPE%-logs}
|
||||
local NGINX_LOGS_PATH="$("fn-nginx-${NGINX_LOGS_TYPE}-log-path" "$APP")"
|
||||
local NGINX_LOGS_PATH="$("fn-nginx-computed-${NGINX_LOGS_TYPE}-log-path" "$APP")"
|
||||
|
||||
if [[ "$NGINX_LOGS_PATH" == "off" ]] || [[ "$NGINX_LOGS_PATH" == "/dev/null" ]]; then
|
||||
dokku_log_fail "$NGINX_LOGS_TYPE logs are disabled for this app"
|
||||
@@ -226,7 +112,7 @@ get_custom_nginx_template() {
|
||||
local IMAGE_TAG="$(get_running_image_tag "$APP")"
|
||||
local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG")
|
||||
local NGINX_TEMPLATE_NAME="nginx.conf.sigil"
|
||||
local DISABLE_CUSTOM_CONFIG="$(fn-plugin-property-get-default "nginx" "$APP" "disable-custom-config" "false")"
|
||||
local DISABLE_CUSTOM_CONFIG="$(fn-nginx-computed-disable-custom-config "$APP")"
|
||||
|
||||
if [[ "$DISABLE_CUSTOM_CONFIG" == "true" ]]; then
|
||||
return
|
||||
@@ -420,15 +306,15 @@ nginx_build_config() {
|
||||
GRPC_SUPPORTED="$(is_grpc_enabled "$NGINX_VERSION")"
|
||||
|
||||
local NGINX_LOG_ROOT="$(fn-nginx-log-root)"
|
||||
local NGINX_ACCESS_LOG_FORMAT="$(fn-nginx-access-log-format "$APP")"
|
||||
local NGINX_ACCESS_LOG_PATH="$(fn-nginx-access-log-path "$APP")"
|
||||
local NGINX_ERROR_LOG_PATH="$(fn-nginx-error-log-path "$APP")"
|
||||
local CLIENT_MAX_BODY_SIZE="$(fn-nginx-client-max-body-size "$APP")"
|
||||
local PROXY_READ_TIMEOUT="$(fn-nginx-proxy-read-timeout "$APP")"
|
||||
local PROXY_BUFFER_SIZE="$(fn-nginx-proxy-buffer-size "$APP")"
|
||||
local PROXY_BUFFERING="$(fn-nginx-proxy-buffering "$APP")"
|
||||
local PROXY_BUFFERS="$(fn-nginx-proxy-buffers "$APP")"
|
||||
local PROXY_BUSY_BUFFERS_SIZE="$(fn-nginx-proxy-busy-buffers-size "$APP")"
|
||||
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_MAX_BODY_SIZE="$(fn-nginx-computed-client-max-body-size "$APP")"
|
||||
local PROXY_READ_TIMEOUT="$(fn-nginx-computed-proxy-read-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")"
|
||||
local PROXY_BUSY_BUFFERS_SIZE="$(fn-nginx-computed-proxy-busy-buffers-size "$APP")"
|
||||
|
||||
if [[ -z "$DOKKU_APP_LISTENERS" ]]; then
|
||||
dokku_log_warn_quiet "No web listeners specified for $APP"
|
||||
@@ -453,14 +339,12 @@ nginx_build_config() {
|
||||
local NGINX_TEMPLATE_SOURCE="app-supplied"
|
||||
fi
|
||||
|
||||
local NGINX_BIND_ADDRESS_IP4="$(fn-nginx-bind-address-ipv4 "$APP")"
|
||||
local NGINX_BIND_ADDRESS_IP6="$(fn-nginx-bind-address-ipv6 "$APP")"
|
||||
[[ -z "$NGINX_BIND_ADDRESS_IP6" ]] && NGINX_BIND_ADDRESS_IP6="::"
|
||||
|
||||
local PROXY_X_FORWARDED_FOR="$(fn-nginx-x-forwarded-for-value "$APP")"
|
||||
local PROXY_X_FORWARDED_PORT="$(fn-nginx-x-forwarded-port-value "$APP")"
|
||||
local PROXY_X_FORWARDED_PROTO="$(fn-nginx-x-forwarded-proto-value "$APP")"
|
||||
local PROXY_X_FORWARDED_SSL="$(fn-nginx-x-forwarded-ssl "$APP")"
|
||||
local NGINX_BIND_ADDRESS_IP4="$(fn-nginx-computed-bind-address-ipv4 "$APP")"
|
||||
local NGINX_BIND_ADDRESS_IP6="$(fn-nginx-computed-bind-address-ipv6 "$APP")"
|
||||
local PROXY_X_FORWARDED_FOR="$(fn-nginx-computed-x-forwarded-for-value "$APP")"
|
||||
local PROXY_X_FORWARDED_PORT="$(fn-nginx-computed-x-forwarded-port-value "$APP")"
|
||||
local PROXY_X_FORWARDED_PROTO="$(fn-nginx-computed-x-forwarded-proto-value "$APP")"
|
||||
local PROXY_X_FORWARDED_SSL="$(fn-nginx-computed-x-forwarded-ssl "$APP")"
|
||||
|
||||
eval "$(config_export app "$APP")"
|
||||
local SIGIL_PARAMS=(-f "$NGINX_TEMPLATE" APP="$APP" DOKKU_ROOT="$DOKKU_ROOT"
|
||||
|
||||
Reference in new issue
Block a user