From 6f4a61855fed86fe4701f9da4319cf80b15b8bd6 Mon Sep 17 00:00:00 2001 From: saiminh Date: Thu, 8 Jan 2026 18:37:31 +1300 Subject: [PATCH] config changes --- DEPLOYMENT.md | 45 ++++++++++++++++++++++++++++++++++++++++++++- nginx.conf.example | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index b956759..8b114b4 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -98,10 +98,53 @@ Then uncomment the HTTPS server block in your nginx config and reload. ## Troubleshooting +### ERR_CONNECTION_REFUSED Errors + +If you see `ERR_CONNECTION_REFUSED` errors for `/_app/immutable/` assets: + +1. **Check if PM2 is running:** + ```bash + pm2 list + ``` + If `floter-design` is not running or shows as `errored`, check logs: + ```bash + pm2 logs floter-design --lines 50 + ``` + +2. **Test if Node.js server responds:** + ```bash + curl http://localhost:3001 + ``` + If this fails, the Node.js server isn't running. + +3. **Check if port 3001 is in use:** + ```bash + sudo netstat -tlnp | grep 3001 + # or + sudo ss -tlnp | grep 3001 + ``` + +4. **Try running the server directly to see errors:** + ```bash + cd ~/floter-design + node build/index.js + ``` + This will show any startup errors. + +5. **Rebuild and restart:** + ```bash + cd ~/floter-design + npm run build + pm2 restart floter-design + ``` + +### Other Common Issues + - **Port already in use**: Change the PORT in `ecosystem.config.cjs` (default is 3001) or stop the process using that port - **Port 3001 conflicts**: You can use any available port (3002, 3003, etc.) - just update both `ecosystem.config.cjs` and your nginx config - **502 Bad Gateway**: Check if the Node.js server is running (`pm2 list`) and check logs (`pm2 logs`) -- **Permission errors**: Make sure the user running PM2 has proper permissions to the `/floter-design` directory +- **Permission errors**: Make sure the user running PM2 has proper permissions to the `~/floter-design` directory +- **Missing dependencies**: Run `npm install` in `~/floter-design` before building ## Environment Variables diff --git a/nginx.conf.example b/nginx.conf.example index 2de3562..b09d042 100644 --- a/nginx.conf.example +++ b/nginx.conf.example @@ -12,17 +12,14 @@ server { listen 80; listen [::]:80; server_name _; # '_' catches all requests, or use your IP address like: 123.45.67.89 - -# OPTION 2: Using domain name (uncomment this and comment out OPTION 1 when you have a domain) -# server { -# listen 80; -# listen [::]:80; -# server_name your-domain.com www.your-domain.com; # Replace with your domain + + # DO NOT set root directive - we're proxying everything to Node.js + # root /var/www/html; # REMOVE THIS if it exists # Redirect HTTP to HTTPS (uncomment after setting up SSL) # return 301 https://$server_name$request_uri; - # For now, proxy directly to Node.js (remove this block after SSL setup) + # Proxy ALL requests (including assets) to Node.js server location / { proxy_pass http://localhost:3001; proxy_http_version 1.1; @@ -38,9 +35,35 @@ server { proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; + + # Ensure all paths are passed through correctly + proxy_redirect off; } } +# OPTION 2: Using domain name (uncomment this and comment out OPTION 1 when you have a domain) +# server { +# listen 80; +# listen [::]:80; +# server_name your-domain.com www.your-domain.com; # Replace with your domain +# +# location / { +# proxy_pass http://localhost:3001; +# proxy_http_version 1.1; +# proxy_set_header Upgrade $http_upgrade; +# proxy_set_header Connection 'upgrade'; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +# proxy_set_header X-Forwarded-Proto $scheme; +# proxy_cache_bypass $http_upgrade; +# +# proxy_connect_timeout 60s; +# proxy_send_timeout 60s; +# proxy_read_timeout 60s; +# } +# } + # When you get a domain, you can add HTTPS configuration below: # HTTPS configuration (uncomment and configure after SSL certificate setup) # server {