Compare commits

...
Author SHA1 Message Date
Thomas Camlong e85c407453 fix: use dedicated internal port to avoid collision with PORT env
If a platform injects PORT=3000 (e.g. Railway), nginx and Next.js
would both try to bind port 3000. Use a dedicated internal port (7901)
for the nginx→Next.js proxy to prevent this.
2026-06-08 16:53:43 +02:00
Thomas Camlong e004afa806 feat: respect PORT env variable for Coolify preview deployments
Nginx now listens on ${PORT} (default 7575) instead of hardcoded 7575,
so Coolify can inject a unique port per preview container. The internal
Next.js server is pinned to port 3000 to avoid conflicting with nginx.
2026-06-08 16:44:16 +02:00
5 changed files with 13 additions and 13 deletions

No files matched your search

+3
View File
@@ -65,5 +65,8 @@ ENV AUTH_PROVIDERS='credentials'
ENV REDIS_IS_EXTERNAL='false'
ENV NODE_ENV='production'
ARG PORT=7575
EXPOSE ${PORT}
ENTRYPOINT [ "/app/entrypoint.sh" ]
CMD ["sh", "run.sh"]
+1 -1
View File
@@ -9,7 +9,7 @@
"dev": "pnpm with-env next dev",
"format": "oxfmt .",
"lint": "oxlint",
"start": "pnpm with-env next start",
"start": "pnpm with-env next start -p ${PORT:-3000}",
"typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --"
},
+1 -1
View File
@@ -1,2 +1,2 @@
:: Please do not run this command in production. It is only for local testing.
docker run -p 7575:7575 -e SECRET_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 homarr:latest
docker run -p 7575:7575 -e PORT=7575 -e SECRET_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 homarr:latest
+3 -5
View File
@@ -4,10 +4,9 @@ events {
http {
server {
listen 7575;
listen [::]:7575;
listen ${PORT};
listen [::]:${PORT};
# Route websockets traffic to port 3001
location /websockets {
proxy_pass http://${HOSTNAME}:3001;
proxy_http_version 1.1;
@@ -16,9 +15,8 @@ http {
proxy_set_header Host $http_host;
}
# Route all other traffic to port 3000
location / {
proxy_pass http://${HOSTNAME}:3000;
proxy_pass http://${HOSTNAME}:${INTERNAL_NEXTJS_PORT};
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+5 -6
View File
@@ -17,12 +17,11 @@ fi
# Auth secret is generated every time the container starts as it is required, but not used because we don't need JWTs or Mail hashing
export AUTH_SECRET=$(openssl rand -base64 32)
# Start nginx proxy
# 1. Replace the HOSTNAME in the nginx template file
# 2. Create the nginx configuration file from the template
# 3. Start the nginx server
export PORT=${PORT:-7575}
export INTERNAL_NEXTJS_PORT=7901
export HOSTNAME
envsubst '${HOSTNAME}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf
envsubst '${HOSTNAME} ${PORT} ${INTERNAL_NEXTJS_PORT}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf
# Start services in the background and store their PIDs
nginx -g 'daemon off;' &
NGINX_PID=$!
@@ -36,7 +35,7 @@ else
REDIS_PID=$!
fi
node apps/nextjs/server.js &
PORT=$INTERNAL_NEXTJS_PORT node apps/nextjs/server.js &
NEXTJS_PID=$!
# Function to handle SIGTERM and shut down services