feat: add proper openresty support
This change allows supporting the openresty package as installed on Ubuntu 18.04 from the official openresty package repository, while also returning general nginx support. Closes #3675
This commit is contained in:
@@ -11,18 +11,7 @@ source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||
|
||||
get_nginx_location() {
|
||||
declare desc="check that nginx is at the expected location and return it"
|
||||
local NGINX_LOCATION
|
||||
|
||||
NGINX_LOCATION=$(which nginx 2>/dev/null)
|
||||
if [[ -z "$NGINX_LOCATION" ]]; then
|
||||
NGINX_LOCATION="/usr/sbin/nginx"
|
||||
fi
|
||||
|
||||
if [[ ! -x "$NGINX_LOCATION" ]]; then
|
||||
dokku_log_fail "Could not find nginx binary in \$PATH or at '${NGINX_LOCATION}'."
|
||||
fi
|
||||
|
||||
echo "$NGINX_LOCATION"
|
||||
fn-nginx-vhosts-nginx-location
|
||||
}
|
||||
|
||||
validate_nginx() {
|
||||
@@ -69,32 +58,18 @@ validate_nginx() {
|
||||
|
||||
restart_nginx() {
|
||||
declare desc="restart nginx for given distros"
|
||||
case "$DOKKU_DISTRO" in
|
||||
debian)
|
||||
sudo /usr/sbin/invoke-rc.d nginx reload >/dev/null
|
||||
;;
|
||||
|
||||
ubuntu)
|
||||
sudo /etc/init.d/nginx reload >/dev/null
|
||||
;;
|
||||
|
||||
opensuse)
|
||||
sudo /sbin/service nginx reload >/dev/null
|
||||
;;
|
||||
|
||||
arch | centos | rhel)
|
||||
sudo /usr/bin/systemctl reload nginx
|
||||
;;
|
||||
esac
|
||||
fn-nginx-vhosts-nginx-init-cmd "reload"
|
||||
}
|
||||
|
||||
nginx_logs() {
|
||||
declare desc="display app nginx logs"
|
||||
local APP="$2"
|
||||
declare NGINX_LOGS_TYPE="${1#nginx:}" APP="$2"
|
||||
local NGINX_LOG_ROOT="/var/log/nginx"
|
||||
verify_app_name "$APP"
|
||||
local NGINX_LOGS_TYPE=${1#nginx:}
|
||||
|
||||
fn-nginx-vhosts-uses-openresty && NGINX_LOG_ROOT="/var/log/openresty"
|
||||
local NGINX_LOGS_TYPE=${NGINX_LOGS_TYPE%-logs}
|
||||
local NGINX_LOGS_PATH="/var/log/nginx/$APP-$NGINX_LOGS_TYPE.log"
|
||||
local NGINX_LOGS_PATH="$NGINX_LOG_ROOT/$APP-$NGINX_LOGS_TYPE.log"
|
||||
|
||||
if [[ $3 == "-t" ]]; then
|
||||
local NGINX_LOGS_ARGS="-F"
|
||||
@@ -372,6 +347,9 @@ nginx_build_config() {
|
||||
|
||||
PROXY_PORT_MAP=$(echo "$PROXY_PORT_MAP" | xargs) # trailing spaces mess up default template
|
||||
|
||||
local NGINX_LOG_ROOT="/var/log/nginx"
|
||||
fn-nginx-vhosts-uses-openresty && NGINX_LOG_ROOT="/var/log/openresty"
|
||||
|
||||
eval "$(config_export app "$APP")"
|
||||
local SIGIL_PARAMS=(-f "$NGINX_TEMPLATE" APP="$APP" DOKKU_ROOT="$DOKKU_ROOT"
|
||||
NOSSL_SERVER_NAME="$NOSSL_SERVER_NAME"
|
||||
@@ -380,6 +358,7 @@ nginx_build_config() {
|
||||
PASSED_LISTEN_IP_PORT="$PASSED_LISTEN_IP_PORT"
|
||||
SPDY_SUPPORTED="$SPDY_SUPPORTED"
|
||||
HTTP2_SUPPORTED="$HTTP2_SUPPORTED"
|
||||
NGINX_LOG_ROOT="$NGINX_LOG_ROOT"
|
||||
HTTP2_PUSH_SUPPORTED="$HTTP2_PUSH_SUPPORTED"
|
||||
GRPC_SUPPORTED="$GRPC_SUPPORTED"
|
||||
DOKKU_APP_LISTEN_PORT="$DOKKU_APP_LISTEN_PORT" DOKKU_APP_LISTEN_IP="$DOKKU_APP_LISTEN_IP"
|
||||
@@ -403,7 +382,7 @@ nginx_build_config() {
|
||||
plugn trigger nginx-pre-reload "$APP" "$DOKKU_APP_LISTEN_PORT" "$DOKKU_APP_LISTEN_IP"
|
||||
|
||||
dokku_log_verbose "Reloading nginx"
|
||||
validate_nginx && restart_nginx
|
||||
validate_nginx && restart_nginx >/dev/null
|
||||
fi
|
||||
|
||||
if ([[ -n "$NONSSL_VHOSTS" ]] || [[ -n "$SSL_VHOSTS" ]]) && [[ "$IS_APP_VHOST_ENABLED" == "true" ]]; then
|
||||
@@ -419,7 +398,7 @@ nginx_build_config() {
|
||||
|
||||
if (is_deployed "$APP"); then
|
||||
dokku_log_info1 "reloading nginx after nginx.conf deletion"
|
||||
validate_nginx && restart_nginx
|
||||
validate_nginx && restart_nginx >/dev/null
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user