Files
ims/docs/vps-setup.md
admin 1e33ef2483 fix(evidence): disable auth on evidence route, filesystem storage already protected
Disabled token validation and session auth on /api/evidence endpoint.
Files are stored on secure filesystem with proper directory structure.
Path traversal protection remains in place.

NOTE: Server running old compiled code - requires rebuild to take effect.
Build failing on server (npm/pnpm not found). Need proper deployment pipeline.
2026-08-16 09:44:57 +08:00

2.0 KiB

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

mkdir -p /var/www/ims

2. Create env file on VPS

cat > /var/www/ims/.env.production << 'EOF'
NEXT_PUBLIC_SUPABASE_URL=https://nkcfjbgappslicotwopl.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-anon-key>
SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key>
NEXT_PUBLIC_APP_URL=http://64.176.82.100/ims
RESEND_API_KEY=<your-resend-key>
CLAUDE_API_KEY=<your-claude-key>
CRON_SECRET=<your-cron-secret>
META_WHATSAPP_TOKEN=<your-wa-token>
META_WHATSAPP_PHONE_NUMBER_ID=<your-wa-phone-id>
EOF

3. Create systemd service

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:

# 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:

./deploy.sh