diff --git a/compose.yaml b/compose.yaml index d69e4d1..29619a6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -59,6 +59,7 @@ services: environment: BACKEND: backend:8000 SOCKETIO: websocket:9000 + NGINX_LISTEN_PORT: ${NGINX_LISTEN_PORT:-8080} FRAPPE_SITE_NAME_HEADER: ${FRAPPE_SITE_NAME_HEADER:-$$host} UPSTREAM_REAL_IP_ADDRESS: ${UPSTREAM_REAL_IP_ADDRESS:-127.0.0.1} UPSTREAM_REAL_IP_HEADER: ${UPSTREAM_REAL_IP_HEADER:-X-Forwarded-For} diff --git a/example.env b/example.env index 1c58dc5..b96a596 100644 --- a/example.env +++ b/example.env @@ -49,6 +49,10 @@ HTTP_PUBLISH_PORT= # Default value is `443`. HTTPS_PUBLISH_PORT= +# Port on which the internal nginx server listens. +# Default value is `8080`. +NGINX_LISTEN_PORT= + # Default value is `127.0.0.1`. Set IP address as our trusted upstream address. UPSTREAM_REAL_IP_ADDRESS= diff --git a/overrides/compose.custom-domain.yaml b/overrides/compose.custom-domain.yaml index ca1b54f..ac1e687 100644 --- a/overrides/compose.custom-domain.yaml +++ b/overrides/compose.custom-domain.yaml @@ -5,7 +5,7 @@ services: - caddy - reverse-proxy - --to - - frontend:8080 + - frontend:${NGINX_LISTEN_PORT:-8080} - --from - :2016 labels: diff --git a/overrides/compose.https.yaml b/overrides/compose.https.yaml index c3bb979..10dbbf5 100644 --- a/overrides/compose.https.yaml +++ b/overrides/compose.https.yaml @@ -2,7 +2,7 @@ services: frontend: labels: - traefik.enable=true - - traefik.http.services.frontend.loadbalancer.server.port=8080 + - traefik.http.services.frontend.loadbalancer.server.port=${NGINX_LISTEN_PORT:-8080} - traefik.http.routers.frontend-http.entrypoints=websecure - traefik.http.routers.frontend-http.tls.certresolver=main-resolver - traefik.http.routers.frontend-http.rule=${SITES_RULE:?SITES_RULE not set} diff --git a/overrides/compose.multi-bench.yaml b/overrides/compose.multi-bench.yaml index e457dd1..c240125 100644 --- a/overrides/compose.multi-bench.yaml +++ b/overrides/compose.multi-bench.yaml @@ -6,7 +6,7 @@ services: labels: - traefik.enable=true - traefik.docker.network=traefik-public - - traefik.http.services.${ROUTER?ROUTER not set}.loadbalancer.server.port=8080 + - traefik.http.services.${ROUTER?ROUTER not set}.loadbalancer.server.port=${NGINX_LISTEN_PORT:-8080} - traefik.http.routers.${ROUTER}-http.service=${ROUTER} - traefik.http.routers.${ROUTER}-http.entrypoints=http - traefik.http.routers.${ROUTER}-http.rule=${SITES_RULE?SITES_RULE not set} diff --git a/overrides/compose.nginxproxy.yaml b/overrides/compose.nginxproxy.yaml index c25ee1a..21b3374 100644 --- a/overrides/compose.nginxproxy.yaml +++ b/overrides/compose.nginxproxy.yaml @@ -2,7 +2,7 @@ services: frontend: environment: VIRTUAL_HOST: ${NGINX_PROXY_HOSTS:?No NGINX_PROXY_HOSTS set} - VIRTUAL_PORT: 8080 + VIRTUAL_PORT: ${NGINX_LISTEN_PORT:-8080} nginx-proxy: image: nginxproxy/nginx-proxy:1.11.6-alpine diff --git a/overrides/compose.noproxy.yaml b/overrides/compose.noproxy.yaml index 23239ff..e32d761 100644 --- a/overrides/compose.noproxy.yaml +++ b/overrides/compose.noproxy.yaml @@ -1,4 +1,4 @@ services: frontend: ports: - - ${HTTP_PUBLISH_PORT:-8080}:8080 + - ${HTTP_PUBLISH_PORT:-8080}:${NGINX_LISTEN_PORT:-8080} diff --git a/overrides/compose.proxy.yaml b/overrides/compose.proxy.yaml index 562dd98..1594ac0 100644 --- a/overrides/compose.proxy.yaml +++ b/overrides/compose.proxy.yaml @@ -2,7 +2,7 @@ services: frontend: labels: - traefik.enable=true - - traefik.http.services.frontend.loadbalancer.server.port=8080 + - traefik.http.services.frontend.loadbalancer.server.port=${NGINX_LISTEN_PORT:-8080} - traefik.http.routers.frontend-http.entrypoints=web - traefik.http.routers.frontend-http.rule=HostRegexp(`^.+$`) diff --git a/overrides/compose.traefik.yaml b/overrides/compose.traefik.yaml index 41c917f..963608c 100644 --- a/overrides/compose.traefik.yaml +++ b/overrides/compose.traefik.yaml @@ -18,7 +18,7 @@ services: # Enable HTTP Basic auth, using the middleware created above - traefik.http.routers.traefik-public-http.middlewares=admin-auth # Define the port inside of the Docker service to use - - traefik.http.services.traefik-public.loadbalancer.server.port=8080 + - traefik.http.services.traefik-public.loadbalancer.server.port=${NGINX_LISTEN_PORT:-8080} command: # Enable Docker in Traefik, so that it reads labels from Docker services - --providers.docker=true diff --git a/resources/core/nginx/nginx-entrypoint.sh b/resources/core/nginx/nginx-entrypoint.sh index 50408e5..44a3f13 100755 --- a/resources/core/nginx/nginx-entrypoint.sh +++ b/resources/core/nginx/nginx-entrypoint.sh @@ -9,6 +9,10 @@ if [[ -z "$SOCKETIO" ]]; then echo "SOCKETIO defaulting to 0.0.0.0:9000" export SOCKETIO=0.0.0.0:9000 fi +if [[ -z "$NGINX_LISTEN_PORT" ]]; then + echo "NGINX_LISTEN_PORT defaulting to 8080" + export NGINX_LISTEN_PORT=8080 +fi if [[ -z "$UPSTREAM_REAL_IP_ADDRESS" ]]; then echo "UPSTREAM_REAL_IP_ADDRESS defaulting to 127.0.0.1" export UPSTREAM_REAL_IP_ADDRESS=127.0.0.1 @@ -41,6 +45,7 @@ fi # shellcheck disable=SC2016 envsubst '${BACKEND} ${SOCKETIO} + ${NGINX_LISTEN_PORT} ${UPSTREAM_REAL_IP_ADDRESS} ${UPSTREAM_REAL_IP_HEADER} ${UPSTREAM_REAL_IP_RECURSIVE} diff --git a/resources/core/nginx/nginx-template.conf b/resources/core/nginx/nginx-template.conf index b7626b5..342e7e4 100644 --- a/resources/core/nginx/nginx-template.conf +++ b/resources/core/nginx/nginx-template.conf @@ -13,7 +13,7 @@ map $http_x_forwarded_proto $proxy_x_forwarded_proto { } server { - listen 8080; + listen ${NGINX_LISTEN_PORT}; server_name ${FRAPPE_SITE_NAME_HEADER}; absolute_redirect off; root /home/frappe/frappe-bench/sites;