2024-07-15 16:15:47 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-07-26 01:18:59 +03:00
|
|
|
if [ "${NGX_HTTP}" = 0 ] ; then
|
|
|
|
unset NGX_HTTP_NO_PROXY NGX_HTTP_WITH_MODSECURITY
|
|
|
|
else
|
2024-07-31 14:04:15 +03:00
|
|
|
NGX_HTTP_NO_PROXY=$(gobool_to_int "${NGX_HTTP_NO_PROXY:-0}" 0)
|
|
|
|
if [ "${NGX_HTTP_NO_PROXY}" = 0 ] ; then
|
|
|
|
NGX_HTTP_CONFLOAD=$(append_list "${NGX_HTTP_CONFLOAD}" proxy)
|
|
|
|
fi
|
|
|
|
|
2024-07-23 21:59:49 +03:00
|
|
|
unset http_modules http_confload
|
2024-07-15 16:15:47 +03:00
|
|
|
http_modules=
|
2024-07-23 21:59:49 +03:00
|
|
|
http_confload="${NGX_HTTP_CONFLOAD:-}"
|
2024-07-15 16:15:47 +03:00
|
|
|
|
2024-07-17 13:50:13 +03:00
|
|
|
if [ -n "${NGX_HTTP_MODULES}" ] ; then
|
|
|
|
## angie-module-lua: depends on angie-module-ndk
|
|
|
|
## angie-module-set-misc: depends on angie-module-ndk
|
2024-07-26 01:18:59 +03:00
|
|
|
|
|
|
|
# unset want_ndk
|
|
|
|
# want_ndk=0
|
|
|
|
# if list_have_item "${NGX_HTTP_MODULES}" lua ; then
|
|
|
|
# want_ndk=1
|
|
|
|
# elif list_have_item "${NGX_HTTP_MODULES}" set-misc ; then
|
|
|
|
# want_ndk=1
|
|
|
|
# fi
|
|
|
|
# if [ ${want_ndk} = 1 ] ; then
|
|
|
|
# NGX_HTTP_MODULES=$(prepend_list "${NGX_HTTP_MODULES}" ndk)
|
|
|
|
# fi
|
|
|
|
# unset want_ndk
|
2024-07-17 13:50:13 +03:00
|
|
|
NGX_HTTP_MODULES=$(
|
|
|
|
printf '%s' "${NGX_HTTP_MODULES}" \
|
|
|
|
| sed -zE 's/(\s|^)(lua|set-misc)(\s|$)/\1ndk \2\3/g'
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
2024-07-15 16:15:47 +03:00
|
|
|
## filter out builtin http modules
|
|
|
|
unset i
|
|
|
|
for i in ${NGX_HTTP_MODULES:-} ; do
|
|
|
|
[ -n "$i" ] || continue
|
|
|
|
|
2024-07-24 22:47:53 +03:00
|
|
|
case "$i" in
|
|
|
|
*/* | *\** | *\?* )
|
|
|
|
log_always "module '$i' is not legal, skipping"
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-07-15 16:15:47 +03:00
|
|
|
if is_builtin_module http "$i" ; then
|
2024-07-24 22:47:53 +03:00
|
|
|
log "$i is builtin module, moving to NGX_HTTP_CONFLOAD"
|
2024-07-26 01:18:59 +03:00
|
|
|
http_confload=$(append_list "${http_confload}" "$i")
|
2024-07-15 16:15:47 +03:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
## naive deduplication
|
2024-07-26 01:18:59 +03:00
|
|
|
if list_have_item "${http_modules}" "$i" ; then
|
2024-07-15 16:15:47 +03:00
|
|
|
log "$i is already specified"
|
|
|
|
continue
|
2024-07-26 01:18:59 +03:00
|
|
|
fi
|
2024-07-15 16:15:47 +03:00
|
|
|
|
2024-07-26 01:18:59 +03:00
|
|
|
http_modules=$(append_list "${http_modules}" "$i")
|
2024-07-15 16:15:47 +03:00
|
|
|
done
|
|
|
|
unset i
|
|
|
|
|
2024-07-31 14:04:15 +03:00
|
|
|
## grpc depends on http/2
|
|
|
|
if list_have_item "${NGX_HTTP_CONFLOAD}" grpc ; then
|
|
|
|
unset want_http2
|
|
|
|
want_http2=0
|
|
|
|
if ! list_have_item "${NGX_HTTP_CONFLOAD}" v2 ; then
|
|
|
|
want_http2=1
|
|
|
|
fi
|
|
|
|
if [ "${want_http2}" = 1 ] ; then
|
|
|
|
NGX_HTTP_CONFLOAD=$(append_list "${NGX_HTTP_CONFLOAD}" v2)
|
|
|
|
fi
|
|
|
|
unset want_http2
|
|
|
|
fi
|
|
|
|
|
2024-07-15 16:15:47 +03:00
|
|
|
set -a
|
|
|
|
NGX_HTTP_MODULES="${http_modules}"
|
2024-07-23 21:59:49 +03:00
|
|
|
NGX_HTTP_CONFLOAD=$(sort_dedup_list "${http_confload}")
|
2024-07-15 16:15:47 +03:00
|
|
|
set +a
|
|
|
|
|
2024-07-23 21:59:49 +03:00
|
|
|
unset http_modules http_confload
|
2024-07-24 22:47:53 +03:00
|
|
|
|
|
|
|
## quirk: angie-module-modsecurity
|
|
|
|
unset NGX_HTTP_WITH_MODSECURITY
|
|
|
|
NGX_HTTP_WITH_MODSECURITY=0
|
|
|
|
while : ; do
|
2024-07-26 01:18:59 +03:00
|
|
|
if ! list_have_item "${NGX_HTTP_MODULES}" modsecurity ; then
|
|
|
|
break
|
|
|
|
fi
|
2024-07-24 22:47:53 +03:00
|
|
|
|
|
|
|
for d in /angie/modules /etc/angie/modules /etc/angie/modules.dist ; do
|
|
|
|
[ -d "$d" ] || continue
|
2024-07-26 01:18:59 +03:00
|
|
|
[ -f "$d/ngx_http_modsecurity_module.so" ] || continue
|
|
|
|
if ! [ -h "$d/ngx_http_modsecurity_module.so" ] ; then
|
2024-07-24 22:47:53 +03:00
|
|
|
NGX_HTTP_WITH_MODSECURITY=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done ; unset d
|
|
|
|
break ; done
|
|
|
|
export NGX_HTTP_WITH_MODSECURITY
|
|
|
|
|
|
|
|
if [ "${NGX_HTTP_WITH_MODSECURITY}" = 1 ] ; then
|
|
|
|
set -a
|
|
|
|
NGX_DIRS_MERGE=$(sort_dedup_list "${NGX_DIRS_MERGE} modsecurity")
|
|
|
|
set +a
|
|
|
|
fi
|
2024-07-15 16:15:47 +03:00
|
|
|
fi
|