# IMS VPS Setup (one-time) VPS: 64.176.82.100 App URL: http://64.176.82.100/ims/ Internal port: 3003 ## 1. Create app directory on VPS ```bash mkdir -p /var/www/ims ``` ## 2. Create env file on VPS ```bash cat > /var/www/ims/.env.production << 'EOF' NEXT_PUBLIC_SUPABASE_URL=https://nkcfjbgappslicotwopl.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY= SUPABASE_SERVICE_ROLE_KEY= NEXT_PUBLIC_APP_URL=http://64.176.82.100/ims RESEND_API_KEY= CLAUDE_API_KEY= CRON_SECRET= META_WHATSAPP_TOKEN= META_WHATSAPP_PHONE_NUMBER_ID= EOF ``` ## 3. Create systemd service ```bash cat > /etc/systemd/system/ims.service << 'EOF' [Unit] Description=IMS Next.js App After=network.target [Service] Type=simple User=www-data WorkingDirectory=/var/www/ims ExecStart=/usr/bin/node server.js Restart=on-failure Environment=NODE_ENV=production Environment=PORT=3003 Environment=HOSTNAME=127.0.0.1 EnvironmentFile=/var/www/ims/.env.production [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable ims systemctl start ims ``` ## 4. Add nginx block Add to `/etc/nginx/sites-available/default` inside the server block: ```nginx # IMS Next.js app location /ims/ { proxy_pass http://127.0.0.1:3003/ims/; 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_cache_bypass $http_upgrade; } # IMS static assets (served directly for performance) location /_next/static/ { proxy_pass http://127.0.0.1:3003/_next/static/; expires 1y; add_header Cache-Control "public, immutable"; } ``` Then: `nginx -t && systemctl reload nginx` ## 5. Supabase dashboard - Authentication > URL Configuration > Site URL: `http://64.176.82.100/ims` - Redirect URLs: add `http://64.176.82.100/ims/api/auth/callback` ## Subsequent deploys From local machine: ```bash ./deploy.sh ```