157 lines
3.4 KiB
Markdown
157 lines
3.4 KiB
Markdown
|
|
# Dexar Market - Deployment Guide
|
||
|
|
|
||
|
|
## Prerequisites
|
||
|
|
- Ubuntu/Debian server with root access
|
||
|
|
- Domain: dexarmarket.ru
|
||
|
|
- Node.js 18+ installed
|
||
|
|
|
||
|
|
## Quick Deployment
|
||
|
|
|
||
|
|
### 1. Build locally
|
||
|
|
```bash
|
||
|
|
npm install
|
||
|
|
npm run build
|
||
|
|
```
|
||
|
|
Output: `dist/dexarmarket/browser/`
|
||
|
|
|
||
|
|
**VERIFY BUILD LOCALLY:**
|
||
|
|
```bash
|
||
|
|
cd dist/dexarmarket/browser
|
||
|
|
ls -la
|
||
|
|
```
|
||
|
|
You MUST see `index.html`, chunk files, `assets/` folder, etc.
|
||
|
|
|
||
|
|
### 2. Upload to server
|
||
|
|
```bash
|
||
|
|
scp -r dist/dexarmarket/browser/* user@your-server:/var/www/dexarmarket/browser/
|
||
|
|
```
|
||
|
|
|
||
|
|
### 3. Set permissions on server
|
||
|
|
```bash
|
||
|
|
sudo chown -R www-data:www-data /var/www/dexarmarket
|
||
|
|
sudo chmod -R 755 /var/www/dexarmarket
|
||
|
|
sudo nginx -t
|
||
|
|
sudo systemctl reload nginx
|
||
|
|
```
|
||
|
|
|
||
|
|
## Initial Server Setup (one-time)
|
||
|
|
|
||
|
|
### Install and configure Nginx
|
||
|
|
```bash
|
||
|
|
sudo apt update
|
||
|
|
sudo apt install nginx -y
|
||
|
|
sudo mkdir -p /var/www/dexarmarket/browser
|
||
|
|
```
|
||
|
|
|
||
|
|
Copy `nginx.conf` content to `/etc/nginx/sites-available/dexarmarket`:
|
||
|
|
```bash
|
||
|
|
sudo nano /etc/nginx/sites-available/dexarmarket
|
||
|
|
```
|
||
|
|
|
||
|
|
Then enable it:
|
||
|
|
```bash
|
||
|
|
sudo ln -s /etc/nginx/sites-available/dexarmarket /etc/nginx/sites-enabled/
|
||
|
|
sudo rm /etc/nginx/sites-enabled/default
|
||
|
|
sudo nginx -t
|
||
|
|
sudo systemctl reload nginx
|
||
|
|
```
|
||
|
|
|
||
|
|
### Setup SSL (recommended)
|
||
|
|
```bash
|
||
|
|
sudo apt install certbot python3-certbot-nginx -y
|
||
|
|
sudo certbot --nginx -d dexarmarket.ru -d www.dexarmarket.ru
|
||
|
|
```
|
||
|
|
|
||
|
|
## Common Issues & Solutions
|
||
|
|
|
||
|
|
### ❌ 404 Error - Files Not Found
|
||
|
|
|
||
|
|
**Check 1: Verify files on server**
|
||
|
|
```bash
|
||
|
|
ls -la /var/www/dexarmarket/browser/
|
||
|
|
```
|
||
|
|
Should show: `index.html`, `chunk-*.js`, `assets/`, etc.
|
||
|
|
|
||
|
|
**If empty:**
|
||
|
|
```bash
|
||
|
|
# Re-upload files
|
||
|
|
scp -r dist/dexarmarket/browser/* user@your-server:/var/www/dexarmarket/browser/
|
||
|
|
```
|
||
|
|
|
||
|
|
**Check 2: Verify permissions**
|
||
|
|
```bash
|
||
|
|
namei -l /var/www/dexarmarket/browser/index.html
|
||
|
|
```
|
||
|
|
All directories need `x` (execute) permission.
|
||
|
|
|
||
|
|
**Fix permissions:**
|
||
|
|
```bash
|
||
|
|
sudo chown -R www-data:www-data /var/www/dexarmarket
|
||
|
|
sudo chmod -R 755 /var/www/dexarmarket
|
||
|
|
```
|
||
|
|
|
||
|
|
**Check 3: Test nginx config**
|
||
|
|
```bash
|
||
|
|
sudo nginx -t
|
||
|
|
```
|
||
|
|
Should say "syntax is ok" and "test is successful".
|
||
|
|
|
||
|
|
**Check 4: View nginx error log**
|
||
|
|
```bash
|
||
|
|
sudo tail -f /var/log/nginx/error.log
|
||
|
|
```
|
||
|
|
This shows the actual error!
|
||
|
|
|
||
|
|
### ❌ 502 Bad Gateway - API Issues
|
||
|
|
|
||
|
|
**This means the API backend is down or unreachable.**
|
||
|
|
|
||
|
|
**Check 1: Is API accessible?**
|
||
|
|
```bash
|
||
|
|
curl -v https://api.dexarmarket.ru:445/ping
|
||
|
|
```
|
||
|
|
|
||
|
|
**Check 2: Port 445 problem**
|
||
|
|
Port 445 is unusual for HTTPS and may be blocked by firewalls. Standard HTTPS uses port 443.
|
||
|
|
|
||
|
|
**Check 3: CORS issues**
|
||
|
|
The API must allow requests from `https://dexarmarket.ru`. Check API CORS configuration.
|
||
|
|
|
||
|
|
**Check 4: SSL certificate**
|
||
|
|
```bash
|
||
|
|
curl -k https://api.dexarmarket.ru:445/ping
|
||
|
|
```
|
||
|
|
If this works but without `-k` doesn't, SSL cert is invalid.
|
||
|
|
|
||
|
|
### ✅ Final Verification Checklist
|
||
|
|
|
||
|
|
On server, run all these:
|
||
|
|
```bash
|
||
|
|
# 1. Files exist
|
||
|
|
ls -la /var/www/dexarmarket/browser/index.html
|
||
|
|
|
||
|
|
# 2. Nginx config is valid
|
||
|
|
sudo nginx -t
|
||
|
|
|
||
|
|
# 3. Nginx is running
|
||
|
|
sudo systemctl status nginx
|
||
|
|
|
||
|
|
# 4. Site is enabled
|
||
|
|
ls -la /etc/nginx/sites-enabled/ | grep dexarmarket
|
||
|
|
|
||
|
|
# 5. Test API from server
|
||
|
|
curl -v https://api.dexarmarket.ru:445/ping
|
||
|
|
|
||
|
|
# 6. Check logs
|
||
|
|
sudo tail -20 /var/log/nginx/error.log
|
||
|
|
sudo tail -20 /var/log/nginx/access.log
|
||
|
|
```
|
||
|
|
|
||
|
|
### Debug Steps
|
||
|
|
|
||
|
|
If still having issues:
|
||
|
|
1. Check browser console (F12 → Console tab) - shows JavaScript errors
|
||
|
|
2. Check browser network tab (F12 → Network tab) - shows failed requests
|
||
|
|
3. Check exact error message in nginx logs
|
||
|
|
4. Test locally: `cd dist/dexarmarket/browser && python3 -m http.server 8000`
|