1
0
Fork 0
This commit is contained in:
root 2023-09-25 13:30:40 -04:00
parent f40a8697bc
commit 5f2bc789c4
3 changed files with 9 additions and 3 deletions

View File

@ -1,7 +1,12 @@
#!/bin/sh #!/bin/sh
# Default to HTTP if PROTOCOL is not set
PROTOCOL="${PROTOCOL:-http}"
# Replace placeholders with environment variable values
envsubst '$BACKEND_ADDRESS $BACKEND_PORT $PROTOCOL' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
# Use envsubst to replace environment variables in nginx.conf.template and output to nginx.conf # Use envsubst to replace environment variables in nginx.conf.template and output to nginx.conf
envsubst '$BACKEND_ADDRESS,$BACKEND_PORT' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf #envsubst '$BACKEND_ADDRESS,$BACKEND_PORT' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
# Start nginx in the foreground # Start nginx in the foreground
exec nginx -g 'daemon off;' exec nginx -g 'daemon off;'

View File

@ -14,7 +14,8 @@ http {
location / { location / {
# Use the placeholders for the proxy pass (these will be replaced by envsubst) # Use the placeholders for the proxy pass (these will be replaced by envsubst)
proxy_pass http://$BACKEND_ADDRESS:$BACKEND_PORT; proxy_pass ${PROTOCOL}://$BACKEND_ADDRESS:$BACKEND_PORT;
# proxy_pass http://$BACKEND_ADDRESS:$BACKEND_PORT;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -9,7 +9,7 @@ services:
image: codeberg.org/iridium-net/lan-to-nginx:latest image: codeberg.org/iridium-net/lan-to-nginx:latest
environment: environment:
- BACKEND_ADDRESS=192.168.8.1 - BACKEND_ADDRESS=192.168.8.1
- BACKEND_PORT=80 - BACKEND_PORT=443
networks: networks:
- traefik - traefik
deploy: deploy: