# Seafile Pro Stack

Seafile Pro 13.0.6 with SeaDoc, SeaSearch, Notification Server, and Metadata Server.

## Important Notes

This stack uses Seafile's official multi-file compose setup. It cannot be deployed via Portainer's git-based stack deployment due to the `COMPOSE_FILE` variable combining multiple yml files.

**Deployment method:** Run from command line with `docker compose up -d`

## Files

- `.env` - All configuration variables
- `seafile-server.yml` - Main Seafile + MariaDB + Redis
- `seadoc.yml` - SeaDoc server
- `seasearch.yml` - SeaSearch server  
- `notification-server.yml` - Notification server
- `md-server.yml` - Metadata server
- `seahub_settings.py` - Seahub Python config (mounted into container)

## Deployment

```bash
cd /mnt/user/appdata/seafile
docker compose up -d
```

## Volumes

All data stored in `/mnt/user/appdata/seafile/`:
- `data/` - Seafile data and file storage
- `db-data/` - MariaDB database
- `seadoc-data/` - SeaDoc data
- `seasearch-data/` - SeaSearch index

## External Dependencies

- **OnlyOffice** - Running in documents stack at `https://office.rishighan.com`
- **NPM Proxy Hosts:**
  - `fileserver.rishighan.com` → `192.168.1.75:8098`
  - `notification.rishighan.com` → `192.168.1.75:8083`

## NPM Advanced Config for fileserver.rishighan.com

```nginx
location / {
    proxy_pass http://192.168.1.75:8098;
    proxy_read_timeout 310s;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Connection "upgrade";
    client_max_body_size 0;
}

rewrite ^/seafdav$ /seafdav/ permanent;

location /sdoc-server/ {
    proxy_pass http://192.168.1.75:8888/;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $server_name;
    client_max_body_size 100m;
}

location /socket.io {
    proxy_pass http://192.168.1.75:8888;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_redirect off;
    proxy_buffers 8 32k;
    proxy_buffer_size 64k;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
}
```

## OnlyOffice JWT

The JWT secret must match between `seahub_settings.py` and OnlyOffice's `/etc/onlyoffice/documentserver/local.json`. Check with:

```bash
docker exec onlyoffice cat /etc/onlyoffice/documentserver/local.json | grep -A2 '"secret"'
```

## Troubleshooting

### "Commit is missing" errors
The seafile data wasn't fully transferred. Re-rsync with proper permissions from source.

### OnlyOffice "document security token" error  
JWT secret mismatch. Update `ONLYOFFICE_JWT_SECRET` in `seahub_settings.py` to match OnlyOffice config.

### Search returns 500 error
Check if SeaSearch is accessible: `docker exec seafile curl -s http://seafile-seasearch:4080`
Check database for missing .ibd files in mysql logs.
