Skip to content

Commit e8a1bc5

Browse files
authored
fix
1 parent 67022d8 commit e8a1bc5

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

pritunl-nginx-proxy/entrypoint.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ while true; do
7575
DEST_VAR="ROUTE_${i}_DESTINATION"
7676
PORT_VAR="ROUTE_${i}_PORT"
7777

78-
# Stop if no more routes
7978
[ -z "${!HOST_VAR}" ] && break
8079

8180
ROUTE_HOST="${!HOST_VAR}"
@@ -89,7 +88,7 @@ while true; do
8988
proxy_pass http://${ROUTE_DEST}:${ROUTE_PORT};
9089
proxy_http_version 1.1;
9190
proxy_set_header Upgrade \$http_upgrade;
92-
proxy_set_header Connection \"upgrade\";
91+
proxy_set_header Connection \"upgrade\" ;
9392
proxy_set_header Host \$host;
9493
proxy_set_header X-Real-IP \$remote_addr;
9594
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
@@ -111,21 +110,17 @@ ${SERVER_BLOCKS[$HOST]}
111110
}"
112111
done
113112

114-
# Process template and inject dynamic blocks
115113
log "Generating Nginx configuration..."
116-
export DYNAMIC_SERVER_BLOCKS
117-
118-
envsubst '${NGINX_PORT} ${PROXY_PASS_DEFAULT} ${PROXY_PORT_DEFAULT} ${ADDITIONAL_ROUTES}' \
119-
< /etc/nginx/templates/nginx.conf.template > /etc/nginx/nginx.conf.tmp
120-
121-
# Inject dynamic server blocks before closing HTTP block
122-
# Escape slashes, backslashes, and ampersands
123-
ESCAPED_BLOCKS=$(echo "${DYNAMIC_SERVER_BLOCKS}" | sed -e 's/[\/&]/\\&/g')
124114

125-
# Inject into nginx.conf
126-
sed -i "/^}$/i ${ESCAPED_BLOCKS}" /etc/nginx/nginx.conf.tmp
127-
128-
mv /etc/nginx/nginx.conf.tmp /etc/nginx/nginx.conf
115+
export DYNAMIC_SERVER_BLOCKS
116+
export ADDITIONAL_ROUTES
117+
export NGINX_PORT
118+
export PROXY_PASS_DEFAULT
119+
export PROXY_PORT_DEFAULT
120+
121+
# Use envsubst to replace the markers
122+
envsubst '${NGINX_PORT} ${PROXY_PASS_DEFAULT} ${PROXY_PORT_DEFAULT} ${ADDITIONAL_ROUTES} ${DYNAMIC_SERVER_BLOCKS}' \
123+
< /etc/nginx/templates/nginx.conf.template > /etc/nginx/nginx.conf
129124

130125
log "Final Nginx configuration:"
131126
cat /etc/nginx/nginx.conf

pritunl-nginx-proxy/nginx.conf.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ http {
4343
proxy_set_header X-Forwarded-Proto $scheme;
4444
}
4545

46-
# Additional location blocks can be added via environment variables
4746
${ADDITIONAL_ROUTES}
4847
}
48+
49+
# ${DYNAMIC_SERVER_BLOCKS}
4950
}

0 commit comments

Comments
 (0)