An open API service indexing awesome lists of open source software.

https://github.com/sh4dowbyte/marzban-nginx


https://github.com/sh4dowbyte/marzban-nginx

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

## 🧩 Marzban + Nginx

**Marzban + Nginx Reverse Proxy** in Docker 🐳

This repository provides a complete setup using **Docker Compose** to run [Marzban](https://github.com/Gozargah/Marzban) (an Xray management panel) with **Nginx reverse proxy** and **SSL certificate** support.

---

### ✨ Features

* πŸ” Nginx reverse proxy for managing VMess, VLESS, Trojan, and Shadowsocks traffic
* πŸ“Š Marzban panel accessible via a public port (`8899`)
* 🌐 Xray protocol access only via reverse proxy (no raw port exposure)
* πŸ“¦ Persistent configuration to ensure data remains safe even after `docker compose down`
* πŸ”§ Compatible with servers without public IPs, optionally integrates with **Cloudflare Tunnel**

---

### πŸ“ Folder Structure

```
.
β”œβ”€β”€ docker-compose.yml # Main Docker Compose file
β”œβ”€β”€ nginx.conf # Main Nginx configuration
β”œβ”€β”€ xray.conf # Reverse proxy virtual host for all protocols
β”œβ”€β”€ marzban/
β”‚ └── xray_config.json # Xray configuration (VMess, VLESS, etc.)
```

---

## πŸš€ Quick Start

Clone this repository and start the services:

```bash
git clone https://github.com/sh4dowByte/marzban-nginx.git
cd marzban-nginx
```

## πŸ” Using SSL (Certbot)

To automatically obtain and install an SSL certificate from Let's Encrypt:

```bash
docker compose up certbot
```

Once completed, the SSL files will be available at:

```bash
./cert/xray/xray.crt
./cert/xray/xray.key
```

Then start the services:

```bash
docker compose up -d marzban nginx
```

Make sure your `.env` file is configured:

```env
CERTBOT_HOSTNAME=your.hostname.com
CERTBOT_EMAIL=your@email.com
```

## ☁️ Using Cloudflare Tunnel

To run Marzban + Nginx + Cloudflare Tunnel (without exposing public ports):

```bash
docker compose up -d marzban nginx cloudflared
```

Ensure your `.env` file contains your Cloudflare Tunnel token:

```env
TUNNEL_TOKEN=your_cloudflare_token
```

---

## ☁️ Secure & Easy Access to Marzban via Cloudflare Tunnel

Want to access your **Marzban panel** securely without exposing ports? Use **Cloudflare Tunnel** with a subpath like:

### 🌐 Example:

![1750807168500](image/readme/1750807168500.png)

Access Marzban at:

```
https://YOUR_DOMAIN/dashboard
```

---

### βš™οΈ Marzban Panel Settings Example:

| VMESS | VLESS | TROJAN |
| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- |
| ![1750776686305](image/readme/1750776686305.png) | ![1750776700384](image/readme/1750776700384.png) | ![1750776717274](image/readme/1750776717274.png) |

---

### ✨ Benefits:

* πŸ”’ **Secure**: No need to expose port 80/443 publicly
* ☁️ **Reliable**: Leverages Cloudflare’s infrastructure β€” perfect for servers without public IPs
* 🎯 **Custom Path**: Run the panel under a subpath like `/dashboard`
* πŸ’‘ **Cost-Effective**: No need for static IP or premium VPS

### ⚠️ Cons:

* πŸ•“ **Slight Latency Overhead** : Requests go through Cloudflare’s edge, adding a small delay compared to direct IP access
* πŸ”§ **Tunnel Dependency** : If the Cloudflare Tunnel fails, access to your panel is lost (unless you expose it directly too)
* πŸ”’ **Cloudflare Account Required** : You must have a Cloudflare account and configure a domain or use a token
* πŸ§ͺ **Debugging Complexity** : Troubleshooting reverse proxy or path issues can be more complex compared to direct hosting

---

### πŸ™ Special Thanks

This project was inspired by and greatly benefited from:

πŸ”— **[Agunxzzz/MarXray](https://github.com/Agunxzzz/MarXray/tree/main)**

An excellent repository that provides a full setup of Marzban + Nginx + Xray, helping lay the foundation for this project’s automatic integration and robust reverse proxy structure.

---

> Thanks to the open-source community for continuously strengthening the Xray and Marzban ecosystem! πŸ’ͺπŸš€

---