Avoiding proxy config wihtout port 80 listening server section

This commit is contained in:
2022-08-23 11:30:26 +00:00
parent 9c0d9c0fc7
commit fdbe2be769

View File

@@ -38,10 +38,17 @@ file="/tmp/$DOMAIN.conf"
{ {
if [[ "$HTTP_PORT" != "" ]]; then if [[ "$HTTP_PORT" != "" ]]; then
DEFAULT_HTTP_PORT=$HTTP_PORT;
if [[ "$HTTP_PORT" == "" ]]; then
DEFAULT_HTTP_PORT="80";
fi
echo "server { echo "server {
listen $HTTP_PORT proxy_protocol; listen $DEFAULT_HTTP_PORT proxy_protocol;
set_real_ip_from 0.0.0.0/0; set_real_ip_from 0.0.0.0/0;
real_ip_header proxy_protocol;" real_ip_header proxy_protocol;"
if [[ "$ALIASES_HTTP" != "" ]]; then if [[ "$ALIASES_HTTP" != "" ]]; then
echo "server_name $DOMAIN_NAME $ALIASES_HTTP;" echo "server_name $DOMAIN_NAME $ALIASES_HTTP;"
else else
@@ -50,15 +57,19 @@ fi
if [[ "$MAX_BODY_SIZE" != "" ]]; then if [[ "$MAX_BODY_SIZE" != "" ]]; then
echo "client_max_body_size "$MAX_BODY_SIZE";" echo "client_max_body_size "$MAX_BODY_SIZE";"
else else
echo "client_max_body_size 0;" echo "client_max_body_size 0;"
fi fi
echo "rewrite_log on;" echo "rewrite_log on;"
if [[ "$REDIRECT_HTTP" != "" && "$HTTP_PORT" != "" ]] ; then if [[ "$REDIRECT_HTTP" != "" && "$HTTP_PORT" != "" ]] ; then
echo "return 301 $REDIRECT_HTTP;" echo "return 301 $REDIRECT_HTTP;"
elif [[ "$HTTP_PORT" == "" ]]; then
echo "return 301 https://"$DOMAIN_NAME;
else else
echo "location / {" echo "location / {"
@@ -75,9 +86,7 @@ echo "rewrite_log on;"
fi fi
if [[ "$HTTP_PORT" != "" ]]; then if [[ "$HTTP_PORT" != "" ]]; then
echo " proxy_pass http://$LOCAL_IP:$HTTP_PORT;" echo " proxy_pass http://$LOCAL_IP:$DEFAULT_HTTP_PORT;"
else
echo " proxy_pass http://$LOCAL_IP:80;"
fi fi
echo " proxy_set_header Host "'$http_host'"; echo " proxy_set_header Host "'$http_host'";