feat: add openresty proxy implementation

This plugin is mostly compatible with the nginx plugin, but runs the proxy within a docker container. Users do not have direct access to add custom openresty configuration at this time, but instead receive the ability to setup automatic ssl on first request via letsencrypt integration.
This commit is contained in:
Jose Diaz-Gonzalez
2023-08-01 02:16:11 -04:00
parent 5846301a48
commit 625ea14c8f
37 changed files with 1371 additions and 86 deletions

View File

@@ -1,79 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
trigger-nginx-vhosts-docker-args-process-deploy() {
declare desc="nginx-vhosts docker-args-process-deploy plugin trigger"
declare trigger="docker-args-process-deploy"
declare APP="$1" IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3" PROC_TYPE="$4" CONTAINER_INDEX="$5"
local output
local STDIN=$(cat)
if [[ "$PROC_TYPE" != "web" ]]; then
return
fi
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
return
fi
if [[ "$(plugn trigger proxy-is-enabled "$APP")" != "true" ]]; then
return
fi
if ! plugn trigger domains-vhost-enabled "$APP" 2>/dev/null; then
return
fi
# ensure we have a port mapping
plugn trigger ports-configure "$APP"
value="$(fn-nginx-access-log-format "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.access-log-format=$value'"
value="$(fn-nginx-bind-address-ipv4 "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.bind-address-ipv4=$value'"
value="$(fn-nginx-bind-address-ipv6 "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.bind-address-ipv6=$value'"
value="$(fn-nginx-client-max-body-size "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.client-max-body-size=$value'"
value="$(fn-nginx-hsts-include-subdomains "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.hsts-include-subdomains=$value'"
value="$(fn-nginx-hsts-max-age "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.hsts-max-age=$value'"
value="$(fn-nginx-hsts-preload "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.hsts-preload=$value'"
value="$(fn-nginx-hsts-is-enabled "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.hsts=$value'"
value="443"
[[ -n "$value" ]] && output="$output '--label=nginx.https-port=$value'"
value="$(plugn trigger domains-list "$APP" | xargs)"
[[ -n "$value" ]] && output="$output '--label=nginx.domains=$value'"
value="$(plugn trigger network-get-property "$APP" initial-network)"
[[ -n "$value" ]] && output="$output '--label=nginx.initial-network=$value'"
value="$(plugn trigger ports-get "$APP" | xargs)"
[[ -n "$value" ]] && output="$output '--label=nginx.port-mapping=$value'"
value="$(fn-nginx-proxy-buffer-size "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.proxy-buffer-size=$value'"
value="$(fn-nginx-proxy-buffering "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.proxy-buffering=$value'"
value="$(fn-nginx-proxy-buffers "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.proxy-buffers=$value'"
value="$(fn-nginx-proxy-busy-buffers-size "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.proxy-busy-buffer-size=$value'"
value="$(fn-nginx-proxy-read-timeout "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.proxy-read-timeout=$value'"
value="$(fn-nginx-x-forwarded-for-value "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.x-forwarded-for-value=$value'"
value="$(fn-nginx-x-forwarded-port-value "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.x-forwarded-port-value=$value'"
value="$(fn-nginx-x-forwarded-proto-value "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.x-forwarded-proto-value=$value'"
value="$(fn-nginx-x-forwarded-ssl "$APP")"
[[ -n "$value" ]] && output="$output '--label=nginx.x-forwarded-ssl=$value'"
echo -n "$STDIN$output"
}
trigger-nginx-vhosts-docker-args-process-deploy "$@"