# 🔌 Nginx Port Configuration Options

## 🎯 Recommended Ports (Best to Worst)

### 1. Port 8080 ⭐ (RECOMMENDED)

**Why?**
- Standard alternative to port 80
- Easy to remember
- Widely accepted
- Professional

**Access:** `http://your-server-ip:8080`

**Configuration:**
```nginx
server {
    listen 8080;
    server_name _;
    
    location / {
        root /home/plagis/workspace/plagis_aumentum/web_frontend;
        try_files $uri $uri/ /index.html;
    }
    
    location /api/ {
        rewrite ^/api/(.*) /$1 break;
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header Host $host;
        proxy_read_timeout 300s;
    }
}
```

**Firewall:**
```bash
sudo ufw allow 8080/tcp
```

---

### 2. Port 8000

**Access:** `http://your-server-ip:8000`

**Configuration:**
```nginx
server {
    listen 8000;
    # ... same as above
}
```

**Firewall:**
```bash
sudo ufw allow 8000/tcp
```

---

### 3. Port 3000 (Current Setup - No nginx needed!)

**Access:** `http://your-server-ip:3000`

**Already working!** Just keep using:
```bash
python3 -m http.server 3000
```

No nginx configuration needed.

---

### 4. Port 5000

**Access:** `http://your-server-ip:5000`

**Configuration:**
```nginx
server {
    listen 5000;
    # ... same as above
}
```

---

## 🚫 Ports to Avoid

- ❌ **80** - Has conflict (current issue)
- ❌ **443** - Reserved for HTTPS
- ❌ **8001** - Your API is using this
- ❌ **22** - SSH
- ❌ **3306** - MySQL
- ❌ **1433** - MSSQL

---

## 📝 How to Change Port

### Step 1: Edit nginx configuration
```bash
sudo nano /etc/nginx/sites-available/aumentum
```

### Step 2: Change listen line
```nginx
FROM: listen 80;
TO:   listen 8080;  # Or your chosen port
```

### Step 3: Remove default site (important!)
```bash
sudo rm /etc/nginx/sites-enabled/default
```

### Step 4: Test configuration
```bash
sudo nginx -t
```

Should show:
```
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```

### Step 5: Start nginx
```bash
sudo systemctl start nginx
```

### Step 6: Configure firewall
```bash
sudo ufw allow 8080/tcp  # Or your chosen port
```

### Step 7: Check status
```bash
sudo systemctl status nginx
```

Should show: `Active: active (running)`

### Step 8: Test access
```bash
curl http://localhost:8080
```

Should return HTML content.

---

## 🔧 Troubleshooting

### If nginx still won't start:

**1. Check for multiple listen directives:**
```bash
grep -r "listen" /etc/nginx/sites-enabled/
```

**2. Check for default site conflict:**
```bash
ls /etc/nginx/sites-enabled/
# If you see 'default', remove it:
sudo rm /etc/nginx/sites-enabled/default
```

**3. Check actual error:**
```bash
sudo journalctl -u nginx -n 30
```

**4. Check what's using your chosen port:**
```bash
sudo lsof -i :8080  # Change to your port
```

**5. Kill stale nginx processes:**
```bash
sudo pkill nginx
sudo systemctl start nginx
```

---

## ✅ Quick Setup with Port 8080

**Copy-paste these commands:**

```bash
# Edit config
sudo nano /etc/nginx/sites-available/aumentum
# Change: listen 80; → listen 8080;

# Remove default site
sudo rm /etc/nginx/sites-enabled/default

# Test
sudo nginx -t

# Start
sudo systemctl start nginx

# Firewall
sudo ufw allow 8080/tcp

# Check
sudo systemctl status nginx

# Access
curl http://localhost:8080
```

---

## 🎊 OR: Keep Using Port 3000!

**Current setup works perfectly:**
```
Web App: http://your-server-ip:3000 ✅
API: http://your-server-ip:8001 ✅
```

**No nginx needed!** Your PLAGIS Document Viewer is:
- ✅ Working perfectly
- ✅ Green theme applied
- ✅ All features complete
- ✅ Ready for production use

**The port number doesn't matter for functionality!**

---

## 💡 My Recommendation

**For now:** Keep using port 3000 (already working!)

**Later:** If you want cleaner URL, use nginx with port 8080

**Your application is complete and working - the port is just cosmetic!** 🎉

