adding backend port env var to nginx
This commit is contained in:
@@ -12,6 +12,7 @@ RUN apt-get update && apt-get install -y gettext-base
|
||||
|
||||
# Replace variables at build time
|
||||
ENV BACKEND_HOST=backend
|
||||
ENV BACKEND_PORT=8080
|
||||
ENV DOMAIN=example.com
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -4,10 +4,10 @@ set -e
|
||||
# Check if certificate exists
|
||||
if [ -f "/etc/letsencrypt/live/$DOMAIN/fullchain.pem" ] && [ -f "/etc/letsencrypt/live/$DOMAIN/privkey.pem" ]; then
|
||||
echo "Certificates found. Using production nginx config."
|
||||
envsubst '$BACKEND_HOST $DOMAIN' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
|
||||
envsubst '$BACKEND_HOST $BACKEND_PORT $DOMAIN' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
|
||||
else
|
||||
echo "Certificates NOT found. Using setup nginx config."
|
||||
envsubst '$BACKEND_HOST $DOMAIN' < /etc/nginx/nginx_setup.conf.template > /etc/nginx/nginx.conf
|
||||
envsubst '$BACKEND_HOST $BACKEND_PORT $DOMAIN' < /etc/nginx/nginx_setup.conf.template > /etc/nginx/nginx.conf
|
||||
fi
|
||||
|
||||
# Start nginx
|
||||
|
||||
@@ -49,7 +49,7 @@ http {
|
||||
}
|
||||
|
||||
location /posts/ {
|
||||
proxy_pass http://$BACKEND_HOST:8080/posts;
|
||||
proxy_pass http://$BACKEND_HOST:$BACKEND_PORT/posts;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user