[English](README.md) | [简体中文](README.zh-Hans.md)

---

## 🎯 Purpose
This guide helps Plex users redirect media playback to direct links generated by [Alist](https://github.com/Xhofe/alist), using nginx and optional Docker deployment. It’s designed for users familiar with Plex, Docker, and basic server configuration.

---

## 🛠️ Setup Steps

### 1. Download Configuration Files

Directory structure after extraction:
```plaintext
~/plex2Alist
├── docker/
│   ├── docker-compose.yml
│   ├── nginx-plex.syno.json
└── nginx/
    ├── conf.d/
    │   ├── api/
    │   ├── cert/
    │   ├── common/
    │   ├── config/
    │   ├── exampleConfig/
    │   ├── includes/
    │   ├── constant.js
    │   ├── plex.conf
    │   └── plex.js
    └── nginx.conf
```

---

### 2. Modify Configuration

- Edit `constant.js` to set your Alist password.
- Default assumes Plex runs on the same machine at port `32400`.

---

### 3. Docker Deployment Options

#### 3.1 Using `docker-compose`
```bash
cd ~/plex2Alist/docker
docker-compose up -d
docker-compose logs -f
```
> Common issues: port conflicts — adjust mapped ports in `docker-compose.yml`.

#### 3.2 Synology Docker
- Go to Container → Settings → Import → Select JSON config → Confirm

---

### 4. Firewall & Port Setup

#### 4.1 HTTP (Default)
- Open port `8091` for Plex direct link proxy
- Open port `8095` for HTTPS (if SSL is configured)
- Add cloud drives in Alist backend → Settings → Token

#### 4.2 HTTPS Configuration
1. Edit `plex.conf`:
   ```nginx
   # include /etc/nginx/conf.d/includes/http.conf;
   include /etc/nginx/conf.d/includes/https.conf;
   ```
2. Set certificate paths in `https.conf`:
   ```nginx
   ssl_certificate /etc/nginx/conf.d/cert/fullchain.pem;
   ssl_certificate_key /etc/nginx/conf.d/cert/privkey.key;
   ```
3. Place your certificate files in `cert/` folder.
4. Reload nginx:
   ```bash
   nginx -s reload
   ```
5. Ensure Docker maps port `8095` correctly and router forwards it if needed.

---

### 5. Plex Server Console Settings

- Enable remote access → set public port to `8091`
- Set custom server access URL: `https://yourdomain:port`
- Leave client settings default
- Do **not** change `proxy_pass` or `plexHost` in `constant.js` — keep `http://` prefix

---

### 6. Plex Client Settings

- Disable auto quality adjustment
- Set streaming quality to highest or original
- Disable bandwidth limits under mobile data settings

---

### 7. Testing

Visit `http://localhost:8091` to test direct link playback.  
Check logs:
```bash
docker logs -f -n 10 nginx-plex 2>&1 | grep js:
```
Or check nginx error logs in `../nginx/log`.

> Port `8091` handles direct links  
> Port `32400` remains for standard Plex server access  
> Set internet quality to highest in Plex settings  
> Web browsers vary in codec support — unsupported formats may trigger transcoding

---

### 8. Additional Notes

- Plex clients (except web) often block non-HTTPS content → strongly recommended to configure domain and SSL
- See `https.conf` for certificate setup
- Ensure `plex.conf` includes HTTPS config

---

## ⚠️ Known Issues

1. **Plex Web Limitations**:
   - No direct playback for DTS audio or external subtitles
   - May freeze or crash on complex formats
   - Use native Plex clients (Android tested and works well)

2. **Client Port Support**:
   - Android: allow unencrypted connections in advanced settings
   - iOS: blocks HTTP — must use HTTPS with domain and certificate

3. **STRM Files**:
   - Plex only displays metadata — cannot play STRM files directly

4. Other issues may arise — feel free to report or comment

---
