Added proxy template for support proxy request from nginx to another service

This commit is contained in:
Alexey Berezhok
2024-10-07 23:21:17 +03:00
parent 9d93d56a05
commit 3225e8cbea
10 changed files with 206 additions and 20 deletions

View File

@@ -254,6 +254,20 @@ prepare_web_domain_values() {
fi
}
convert_proxy_ngix_internal_redirect(){
proxy_port="$1"
if [[ "$proxy_port" =~ ^[0-9]+$ ]];then
echo "localhost:${proxy_port}"
return 0
fi
if [[ "$proxy_port" =~ ^/ ]];then
echo "unix:${proxy_port}"
return 0
fi
echo "localhost:9999"
return 1
}
# Add web config
add_web_config() {
# Check if folder already exists
@@ -316,6 +330,14 @@ add_web_config() {
-e "s|%ssl_ca_str%|$ssl_ca_str|g" \
-e "s|%ssl_ca%|$ssl_ca|g" \
> $conf
if [ "$2" == "srvproxy.tpl" -o "$2" == "srvproxy.stpl" ];then
proxy_backend_port_internal=$(convert_proxy_ngix_internal_redirect "$3")
cat "$conf" \
| sed -e "s|%proxy_backend_srv_port%|$proxy_backend_port_internal|g" \
> $conf.tmp
mv -f ${conf}.tmp $conf
fi
process_http2_directive "$conf"