fix: resolve EADDRINUSE port conflict — Node.js now listens on internal port 4000
Nginx listens publicly on 2087/2083 and reverse-proxies to 127.0.0.1:4000. Previously both Nginx and Node.js were trying to bind port 2087 causing the nixpanel service to crash-loop. HOST changed to 127.0.0.1 so the API is not directly reachable from outside. Bumps version to 0.3.1.
This commit is contained in:
+17
-10
@@ -28,7 +28,7 @@ cat <<'EOF'
|
||||
Open-Source Web Hosting Control Panel
|
||||
EOF
|
||||
echo -e "${RESET}"
|
||||
echo -e " Version : ${BOLD}0.3.0${RESET}"
|
||||
echo -e " Version : ${BOLD}0.3.1${RESET}"
|
||||
echo -e " GitHub : ${BOLD}https://github.com/NixReaper/nixpanel-server${RESET}"
|
||||
echo -e " NixServer: ${BOLD}https://<your-ip>:2087${RESET}"
|
||||
echo -e " NixClient: ${BOLD}https://<your-ip>:2083${RESET}"
|
||||
@@ -351,11 +351,11 @@ JWT_EXPIRES_IN="15m"
|
||||
JWT_REFRESH_SECRET="${JWT_REFRESH_SECRET}"
|
||||
JWT_REFRESH_EXPIRES_IN="7d"
|
||||
|
||||
# Server
|
||||
# Server (internal ports — Nginx proxies public 2087/2083 → these)
|
||||
NODE_ENV="production"
|
||||
NIXSERVER_PORT=2087
|
||||
NIXCLIENT_PORT=2083
|
||||
HOST="0.0.0.0"
|
||||
NIXSERVER_PORT=4000
|
||||
NIXCLIENT_PORT=4001
|
||||
HOST="127.0.0.1"
|
||||
|
||||
# Admin credentials (used during initial seed only)
|
||||
ADMIN_USERNAME="${ADMIN_USER}"
|
||||
@@ -465,6 +465,13 @@ fi
|
||||
|
||||
cat > /etc/nginx/sites-available/nixpanel.conf <<NGINX
|
||||
# NixPanel — generated by installer
|
||||
# Node.js API listens on 127.0.0.1:4000 (internal only)
|
||||
# Nginx proxies public ports 2087/2083 → internal API
|
||||
|
||||
upstream nixpanel_api {
|
||||
server 127.0.0.1:4000;
|
||||
}
|
||||
|
||||
# NixServer admin panel on port 2087
|
||||
server {
|
||||
listen 2087;
|
||||
@@ -479,7 +486,7 @@ server {
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:2087;
|
||||
proxy_pass http://nixpanel_api;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade \$http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
@@ -490,7 +497,7 @@ server {
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:2087;
|
||||
proxy_pass http://nixpanel_api;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade \$http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
@@ -510,7 +517,7 @@ server {
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:2087;
|
||||
proxy_pass http://nixpanel_api;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade \$http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
@@ -631,13 +638,13 @@ step "Waiting for NixPanel to start"
|
||||
|
||||
MAX_WAIT=30
|
||||
WAITED=0
|
||||
until curl -sf http://127.0.0.1:2087/api/health >/dev/null 2>&1; do
|
||||
until curl -sf http://127.0.0.1:4000/api/health >/dev/null 2>&1; do
|
||||
sleep 2
|
||||
WAITED=$((WAITED + 2))
|
||||
[[ $WAITED -ge $MAX_WAIT ]] && { warn "Service health check timed out — check: journalctl -u nixpanel -n 50"; break; }
|
||||
done
|
||||
|
||||
if curl -sf http://127.0.0.1:2087/api/health >/dev/null 2>&1; then
|
||||
if curl -sf http://127.0.0.1:4000/api/health >/dev/null 2>&1; then
|
||||
success "NixPanel API is responding"
|
||||
else
|
||||
warn "NixPanel may still be starting. Check status with: systemctl status nixpanel"
|
||||
|
||||
Reference in New Issue
Block a user