# Host sarmad.pro on this VPS (not GitHub Pages)

## What runs where

| Path | Served by |
|------|-----------|
| `/`, `/*.html`, `/style.css` | nginx → `/var/www/sarmad.pro` |
| `/downloads/*` (APK, coordinator zip) | nginx → `/var/www/sarmad.pro/downloads` |
| `/v1/*`, `/v1/ws`, `/web/*`, `/node.html` (redirects), `/coordinator.html` | nginx proxy → Node coordinator `:9334` |

Config file on VPS: `/etc/nginx/sites-available/sarmad.pro`  
(source in repo: `vps_scheduler/nginx-sarmad.pro.conf`)

## Deploy site files

From your PC (PowerShell):

```powershell
$site = "C:\Users\hatim\Documents\Sarmad-Pro-site-v11"
$scp = @("-i", "$env:USERPROFILE\.ssh\sarmad_vps", "-o", "StrictHostKeyChecking=accept-new")
scp @scp "$site\index.html","$site\mining.html","$site\market.html","$site\node.html","$site\investment-admin.html","$site\style.css" "root@78.47.21.219:/var/www/sarmad.pro/"
scp @scp "$site\downloads\SRMD1.15.apk" "root@78.47.21.219:/var/www/sarmad.pro/downloads/"
```

Coordinator zip (too large for GitHub):

```powershell
scp @scp "...\coordinator_exe\dist-electron\SRMD-Coordinator-1.16.zip" "root@78.47.21.219:/var/www/sarmad.pro/downloads/"
```

## Directory failover (Step 1)

APK and EXE try directories in order until `/v1/status` answers:

1. `http://78.47.21.219:9334` (primary)
2. `https://sarmad.pro` (nginx → same coordinator; helps when :9334 is blocked)
3. `https://www.sarmad.pro`

Override on EXE: `SARMAD_DIRECTORY_URL` (force first) or `SARMAD_DIRECTORY_URLS=url1,url2,...`

When you add a second independent directory host, append it to:
- `ProtocolConstants.COORDINATOR_DIRECTORY_URLS` (APK)
- `vps_scheduler/directory_urls.js` / `coordinator_exe/directory_urls.js` (EXE)

## DNS cutover (required for https://sarmad.pro)

Today `sarmad.pro` points at **GitHub Pages**. Change at your DNS registrar:

1. Remove the GitHub Pages **CNAME** (or Pages custom domain).
2. Add an **A** record: `sarmad.pro` → `78.47.21.219`
3. Optional: `www` **A** → `78.47.21.219` (or CNAME → `sarmad.pro`)

Until DNS updates, the site is already live at:

- http://78.47.21.219/
- http://78.47.21.219/mining.html
- http://78.47.21.219/downloads/SRMD-Coordinator-1.16.zip

## HTTPS (after DNS points here)

```bash
apt-get install -y certbot python3-certbot-nginx
certbot --nginx -d sarmad.pro -d www.sarmad.pro
```

## Note on the protocol repo

The Android/protocol git repo can stay on GitHub for source control. Only **website hosting + large binaries** need the VPS. You do not have to move source code off GitHub unless you want to.
