Fixing HTTP empty string and HTTPS_PORT variable usage cases

This commit is contained in:
2022-09-20 10:27:54 +00:00
parent 0b16b57551
commit 3de68bf07b

View File

@@ -37,15 +37,19 @@ file="/tmp/$DOMAIN.conf"
{ {
if [[ "$HTTP_PORT" != "" ]]; then if [[ "$HTTP_PORT" != "80" || "$HTTP_PORT" == "" ]]; then
DEFAULT_HTTP_PORT=$HTTP_PORT; echo "server {
listen 80 proxy_protocol;
set_real_ip_from 0.0.0.0/0;
real_ip_header proxy_protocol;
rewrite_log on;
return 301 https://$DOMAIN_NAME;
}"
if [[ "$HTTP_PORT" == "" ]]; then
DEFAULT_HTTP_PORT="80";
fi fi
echo "server { echo "server {
listen 80 proxy_protocol; listen $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;"
@@ -115,7 +119,6 @@ echo "rewrite_log on;"
fi fi
fi fi
echo "}" echo "}"
fi
if [[ "$HTTPS_PORT" != "" ]]; then if [[ "$HTTPS_PORT" != "" ]]; then
echo "server { echo "server {
@@ -173,11 +176,7 @@ location = /$ERROR_PAGE {
done done
echo " deny all;" echo " deny all;"
fi fi
if [[ "$HTTPS_PORT" != "" ]]; then
echo " proxy_pass http://$LOCAL_IP:$HTTPS_PORT;" echo " proxy_pass http://$LOCAL_IP:$HTTPS_PORT;"
else
echo " proxy_pass http://$LOCAL_IP:80;"
fi
echo " proxy_set_header Host "'$http_host'"; echo " proxy_set_header Host "'$http_host'";
proxy_set_header X-Real-IP "'$remote_addr'"; proxy_set_header X-Real-IP "'$remote_addr'";