| 1 |
df3ebf4 |
Mrdn |
2y ago |
<h1 align="center"/>Marzneshin</h1> |
| 2 |
a47eb4c |
Dawsh |
2y ago |
|
| 3 |
a47eb4c |
Dawsh |
2y ago |
<p align="center"> |
| 4 |
bfd37dd |
Mrdn |
2y ago |
A Scalable and Comprehensive Proxy Engine management panel. |
| 5 |
a47eb4c |
Dawsh |
2y ago |
</p> |
| 6 |
a47eb4c |
Dawsh |
2y ago |
|
| 7 |
a47eb4c |
Dawsh |
2y ago |
<br/> |
| 8 |
a47eb4c |
Dawsh |
2y ago |
<p align="center"> |
| 9 |
91055d4 |
Mrdn |
2y ago |
<a href="https://github.com/khodedawsh/Marzneshin/actions/workflows/dashboard-ci.yml"> |
| 10 |
91055d4 |
Mrdn |
2y ago |
<img src="https://github.com/khodedawsh/Marzneshin/actions/workflows/dashboard-ci.yml/badge.svg" /> |
| 11 |
91055d4 |
Mrdn |
2y ago |
</a> |
| 12 |
91055d4 |
Mrdn |
2y ago |
<a href="https://github.com/khodedawsh/Marzneshin/actions/workflows/package.yml" target="_blank"> |
| 13 |
91055d4 |
Mrdn |
2y ago |
<img src="https://github.com/khodedawsh/Marzneshin/actions/workflows/package.yml/badge.svg" /> |
| 14 |
a47eb4c |
Dawsh |
2y ago |
</a> |
| 15 |
953c697 |
Dawsh |
2y ago |
<a href="https://hub.docker.com/r/dawsh/marzneshin" target="_blank"> |
| 16 |
bf00248 |
Dawsh |
2y ago |
<img src="https://img.shields.io/docker/pulls/dawsh/marzneshin?style=flat-square&logo=docker" /> |
| 17 |
a47eb4c |
Dawsh |
2y ago |
</a> |
| 18 |
91055d4 |
Mrdn |
2y ago |
<br> |
| 19 |
a47eb4c |
Dawsh |
2y ago |
<a href="#"> |
| 20 |
bf00248 |
Dawsh |
2y ago |
<img src="https://img.shields.io/github/license/khodedawsh/marzneshin?style=flat-square" /> |
| 21 |
a47eb4c |
Dawsh |
2y ago |
</a> |
| 22 |
bf00248 |
Dawsh |
2y ago |
<a href="https://t.me/marzneshins" target="_blank"> |
| 23 |
a47eb4c |
Dawsh |
2y ago |
<img src="https://img.shields.io/badge/telegram-group-blue?style=flat-square&logo=telegram" /> |
| 24 |
a47eb4c |
Dawsh |
2y ago |
</a> |
| 25 |
a47eb4c |
Dawsh |
2y ago |
<a href="#"> |
| 26 |
a47eb4c |
Dawsh |
2y ago |
<img src="https://img.shields.io/badge/twitter-commiunity-blue?style=flat-square&logo=twitter" /> |
| 27 |
a47eb4c |
Dawsh |
2y ago |
</a> |
| 28 |
a47eb4c |
Dawsh |
2y ago |
<a href="#"> |
| 29 |
bf00248 |
Dawsh |
2y ago |
<img src="https://img.shields.io/github/stars/khodedawsh/marzneshin?style=social" /> |
| 30 |
a47eb4c |
Dawsh |
2y ago |
</a> |
| 31 |
a47eb4c |
Dawsh |
2y ago |
</p> |
| 32 |
a47eb4c |
Dawsh |
2y ago |
|
| 33 |
a47eb4c |
Dawsh |
2y ago |
<p align="center"> |
| 34 |
953c697 |
Dawsh |
2y ago |
<a href="https://github.com/khodedawsh/marzneshin" target="_blank" rel="noopener noreferrer" > |
| 35 |
bfd37dd |
Mrdn |
2y ago |
<img src="https://github.com/Gozargah/Marzban-docs/raw/master/screenshots/preview.png" alt="screenshots" width="600" height="auto"> |
| 36 |
a47eb4c |
Dawsh |
2y ago |
</a> |
| 37 |
a47eb4c |
Dawsh |
2y ago |
</p> |
| 38 |
a47eb4c |
Dawsh |
2y ago |
|
| 39 |
a47eb4c |
Dawsh |
2y ago |
## Table of Contents |
| 40 |
a47eb4c |
Dawsh |
2y ago |
|
| 41 |
a47eb4c |
Dawsh |
2y ago |
- [Overview](#overview) |
| 42 |
5c78ce8 |
Dawsh |
2y ago |
- [Features](#features) |
| 43 |
5c78ce8 |
Dawsh |
2y ago |
- [Supported Languages](#supported-languages) |
| 44 |
a47eb4c |
Dawsh |
2y ago |
- [Installation guide](#installation-guide) |
| 45 |
a47eb4c |
Dawsh |
2y ago |
- [Configuration](#configuration) |
| 46 |
a47eb4c |
Dawsh |
2y ago |
- [API](#api) |
| 47 |
a47eb4c |
Dawsh |
2y ago |
- [Backup](#backup) |
| 48 |
a47eb4c |
Dawsh |
2y ago |
- [Telegram Bot](#telegram-bot) |
| 49 |
bf00248 |
Dawsh |
2y ago |
- [Marzneshin CLI](#marzneshin-cli) |
| 50 |
ece2ed6 |
Dawsh |
2y ago |
- [Marznode](#marznode) |
| 51 |
a47eb4c |
Dawsh |
2y ago |
- [Webhook notifications](#webhook-notifications) |
| 52 |
a47eb4c |
Dawsh |
2y ago |
- [Donation](#donation) |
| 53 |
a47eb4c |
Dawsh |
2y ago |
- [License](#license) |
| 54 |
a47eb4c |
Dawsh |
2y ago |
- [Contributors](#contributors) |
| 55 |
a47eb4c |
Dawsh |
2y ago |
|
| 56 |
a47eb4c |
Dawsh |
2y ago |
# Overview |
| 57 |
a47eb4c |
Dawsh |
2y ago |
|
| 58 |
bfd37dd |
Mrdn |
2y ago |
Marzneshin is a censorship circumvention tool utilizing other censorship circumvention tools. |
| 59 |
a47eb4c |
Dawsh |
2y ago |
|
| 60 |
5c78ce8 |
Dawsh |
2y ago |
Dashboard enables access to nodes(configurations, status and stats, logs), |
| 61 |
bfd37dd |
Mrdn |
2y ago |
hosts, users, service entities; while providing monitoring and system statistics. |
| 62 |
a47eb4c |
Dawsh |
2y ago |
|
| 63 |
5c78ce8 |
Dawsh |
2y ago |
On the other hand, the backend manages nodes, users, users' subscriptions, etc. |
| 64 |
a47eb4c |
Dawsh |
2y ago |
|
| 65 |
5c78ce8 |
Dawsh |
2y ago |
Marzneshin controls the [Marznodes](https://github.com/khodedawsh/marznode) |
| 66 |
bfd37dd |
Mrdn |
2y ago |
connected to it; monitoring/disabling/enabling users on marznode instances while |
| 67 |
bfd37dd |
Mrdn |
2y ago |
marznode manages and interacts with vpn backends (such as xray). |
| 68 |
a47eb4c |
Dawsh |
2y ago |
|
| 69 |
bfd37dd |
Mrdn |
2y ago |
### Features |
| 70 |
bfd37dd |
Mrdn |
2y ago |
|
| 71 |
5c78ce8 |
Dawsh |
2y ago |
- **Web UI** Dashboard |
| 72 |
bfd37dd |
Mrdn |
2y ago |
- **Multi Nodes** support for traffic distribution, scalability, and fault tolerance |
| 73 |
bfd37dd |
Mrdn |
2y ago |
- Supports protocols **Vmess**, **VLESS**, **Trojan** and **Shadowsocks** as provided by xray |
| 74 |
a47eb4c |
Dawsh |
2y ago |
- **Multi-protocol** for a single user |
| 75 |
bfd37dd |
Mrdn |
2y ago |
- Manage users' access to inbounds separately |
| 76 |
a47eb4c |
Dawsh |
2y ago |
- **Multi-user** on a single inbound |
| 77 |
bfd37dd |
Mrdn |
2y ago |
- Limit users' data and set exire dates |
| 78 |
bf00248 |
Dawsh |
2y ago |
- reset traffic periodically (daily, weekly,...) |
| 79 |
bfd37dd |
Mrdn |
2y ago |
- **Subscription link** compatible with **V2ray** (e.g. V2RayNG, OneClick, Nekoray, etc.), **Clash** and **ClashMeta** |
| 80 |
a47eb4c |
Dawsh |
2y ago |
- Automated **Share link** and **QRcode** generator |
| 81 |
5c78ce8 |
Dawsh |
2y ago |
- System, nodes, traffic statistics, users monitoring |
| 82 |
a47eb4c |
Dawsh |
2y ago |
- Integrated **Command Line Interface (CLI)** |
| 83 |
a47eb4c |
Dawsh |
2y ago |
- **Multi-admin** support (WIP) |
| 84 |
bfd37dd |
Mrdn |
2y ago |
- Marzneshin is decoupled from VPN backends |
| 85 |
bfd37dd |
Mrdn |
2y ago |
- Resilient and fault tolerant node management |
| 86 |
bfd37dd |
Mrdn |
2y ago |
- UI performance and redesign |
| 87 |
a47eb4c |
Dawsh |
2y ago |
|
| 88 |
bfd37dd |
Mrdn |
2y ago |
Deployment and Developer Kit: |
| 89 |
5c78ce8 |
Dawsh |
2y ago |
|
| 90 |
bfd37dd |
Mrdn |
2y ago |
- REST-full API |
| 91 |
bfd37dd |
Mrdn |
2y ago |
- Kubernetes and multiple deployment strategy and options (WIP) |
| 92 |
bfd37dd |
Mrdn |
2y ago |
|
| 93 |
bfd37dd |
Mrdn |
2y ago |
### Supported Languages |
| 94 |
5c78ce8 |
Dawsh |
2y ago |
|
| 95 |
bfd37dd |
Mrdn |
2y ago |
- Russian (WIP) |
| 96 |
5c78ce8 |
Dawsh |
2y ago |
- English |
| 97 |
bfd37dd |
Mrdn |
2y ago |
- Kurdish (Soranî, Kurmancî) |
| 98 |
bfd37dd |
Mrdn |
2y ago |
- Persian (WIP) |
| 99 |
bf00248 |
Dawsh |
2y ago |
|
| 100 |
a47eb4c |
Dawsh |
2y ago |
# Installation guide |
| 101 |
a47eb4c |
Dawsh |
2y ago |
|
| 102 |
a47eb4c |
Dawsh |
2y ago |
Run the following command |
| 103 |
a47eb4c |
Dawsh |
2y ago |
|
| 104 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 105 |
bf00248 |
Dawsh |
2y ago |
sudo bash -c "$(curl -sL https://github.com/khodedawsh/Marzneshin/raw/master/script.sh)" @ install |
| 106 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 107 |
a47eb4c |
Dawsh |
2y ago |
|
| 108 |
ece2ed6 |
Dawsh |
2y ago |
To install with mariadb: |
| 109 |
ece2ed6 |
Dawsh |
2y ago |
|
| 110 |
ece2ed6 |
Dawsh |
2y ago |
```bash |
| 111 |
ece2ed6 |
Dawsh |
2y ago |
sudo bash -c "$(curl -sL https://github.com/khodedawsh/Marzneshin/raw/master/script.sh)" @ install --database mariadb |
| 112 |
ece2ed6 |
Dawsh |
2y ago |
``` |
| 113 |
5c78ce8 |
Dawsh |
2y ago |
|
| 114 |
ece2ed6 |
Dawsh |
2y ago |
You could also use mysql by writing mysql instead, however mariadb is **recommended**. |
| 115 |
ece2ed6 |
Dawsh |
2y ago |
Also to install the latest nightly release use the `--nightly` option. |
| 116 |
ece2ed6 |
Dawsh |
2y ago |
|
| 117 |
a47eb4c |
Dawsh |
2y ago |
Once the installation is complete: |
| 118 |
a47eb4c |
Dawsh |
2y ago |
|
| 119 |
bf00248 |
Dawsh |
2y ago |
- You'd notice the logs, which you could stop watching by pressing `Ctrl+C`; The process will continue running normally. |
| 120 |
5c78ce8 |
Dawsh |
2y ago |
- the configuration file can be found at `/etc/opt/marzneshin/.env` (refer to [configurations](#configuration) section |
| 121 |
5c78ce8 |
Dawsh |
2y ago |
to see variables) |
| 122 |
bf00248 |
Dawsh |
2y ago |
- Data files will be placed at `/var/lib/marzneshin`; e.g. the sqlite database. |
| 123 |
5c78ce8 |
Dawsh |
2y ago |
- You can access the Marzneshin dashboard by opening a web browser and navigating |
| 124 |
5c78ce8 |
Dawsh |
2y ago |
to `http://<SERVER_IP>:8000/dashboard/` |
| 125 |
a47eb4c |
Dawsh |
2y ago |
|
| 126 |
bf00248 |
Dawsh |
2y ago |
Next, you need to create a sudo admin for logging into the Marzneshin dashboard by the following command |
| 127 |
a47eb4c |
Dawsh |
2y ago |
|
| 128 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 129 |
bf00248 |
Dawsh |
2y ago |
marzneshin cli admin create --sudo |
| 130 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 131 |
a47eb4c |
Dawsh |
2y ago |
|
| 132 |
a47eb4c |
Dawsh |
2y ago |
That's it! You can login to your dashboard using these credentials |
| 133 |
a47eb4c |
Dawsh |
2y ago |
|
| 134 |
bf00248 |
Dawsh |
2y ago |
To see the help message of the Marzneshin script, run the following command |
| 135 |
a47eb4c |
Dawsh |
2y ago |
|
| 136 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 137 |
bf00248 |
Dawsh |
2y ago |
marzneshin --help |
| 138 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 139 |
a47eb4c |
Dawsh |
2y ago |
|
| 140 |
a47eb4c |
Dawsh |
2y ago |
If you are eager to run the project using the source code, check the section below |
| 141 |
a47eb4c |
Dawsh |
2y ago |
<details markdown="1"> |
| 142 |
a47eb4c |
Dawsh |
2y ago |
<summary><h3>Manual install (advanced)</h3></summary> |
| 143 |
a47eb4c |
Dawsh |
2y ago |
|
| 144 |
a47eb4c |
Dawsh |
2y ago |
Install xray on your machine |
| 145 |
a47eb4c |
Dawsh |
2y ago |
|
| 146 |
a47eb4c |
Dawsh |
2y ago |
You can install it using [Xray-install](https://github.com/XTLS/Xray-install) |
| 147 |
a47eb4c |
Dawsh |
2y ago |
|
| 148 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 149 |
a47eb4c |
Dawsh |
2y ago |
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install |
| 150 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 151 |
a47eb4c |
Dawsh |
2y ago |
|
| 152 |
bf00248 |
Dawsh |
2y ago |
Clone this project and install the dependencies (you'd need Python >= 3.10) |
| 153 |
a47eb4c |
Dawsh |
2y ago |
|
| 154 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 155 |
bf00248 |
Dawsh |
2y ago |
git clone https://github.com/khodedawsh/Marzneshin |
| 156 |
bf00248 |
Dawsh |
2y ago |
cd Marzneshin/ |
| 157 |
a47eb4c |
Dawsh |
2y ago |
wget -qO- https://bootstrap.pypa.io/get-pip.py | python3 - |
| 158 |
a47eb4c |
Dawsh |
2y ago |
python3 -m pip install -r requirements.txt |
| 159 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 160 |
a47eb4c |
Dawsh |
2y ago |
|
| 161 |
a47eb4c |
Dawsh |
2y ago |
Alternatively, to have an isolated environment you can use [Python Virtualenv](https://pypi.org/project/virtualenv/) |
| 162 |
a47eb4c |
Dawsh |
2y ago |
|
| 163 |
a47eb4c |
Dawsh |
2y ago |
Then run the following command to run the database migration scripts |
| 164 |
a47eb4c |
Dawsh |
2y ago |
|
| 165 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 166 |
a47eb4c |
Dawsh |
2y ago |
alembic upgrade head |
| 167 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 168 |
a47eb4c |
Dawsh |
2y ago |
|
| 169 |
5c78ce8 |
Dawsh |
2y ago |
If you want to use `marzneshin-cli`, you should link it to a file in your `$PATH`, make it executable, and install the |
| 170 |
5c78ce8 |
Dawsh |
2y ago |
auto-completion: |
| 171 |
a47eb4c |
Dawsh |
2y ago |
|
| 172 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 173 |
bf00248 |
Dawsh |
2y ago |
sudo ln -s $(pwd)/marzneshin-cli.py /usr/bin/marzneshin-cli |
| 174 |
bf00248 |
Dawsh |
2y ago |
sudo chmod +x /usr/bin/marzneshin-cli |
| 175 |
bf00248 |
Dawsh |
2y ago |
marzneshin-cli completion install |
| 176 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 177 |
a47eb4c |
Dawsh |
2y ago |
|
| 178 |
a47eb4c |
Dawsh |
2y ago |
Now it's time to configuration |
| 179 |
a47eb4c |
Dawsh |
2y ago |
|
| 180 |
a47eb4c |
Dawsh |
2y ago |
Make a copy of `.env.example` file, take a look and edit it using a text editor like `nano`. |
| 181 |
a47eb4c |
Dawsh |
2y ago |
|
| 182 |
a47eb4c |
Dawsh |
2y ago |
You probably like to modify the admin credentials. |
| 183 |
a47eb4c |
Dawsh |
2y ago |
|
| 184 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 185 |
a47eb4c |
Dawsh |
2y ago |
cp .env.example .env |
| 186 |
a47eb4c |
Dawsh |
2y ago |
nano .env |
| 187 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 188 |
a47eb4c |
Dawsh |
2y ago |
|
| 189 |
a47eb4c |
Dawsh |
2y ago |
> Check [configurations](#configuration) section for more information |
| 190 |
a47eb4c |
Dawsh |
2y ago |
|
| 191 |
a47eb4c |
Dawsh |
2y ago |
Eventually, launch the application using command below |
| 192 |
a47eb4c |
Dawsh |
2y ago |
|
| 193 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 194 |
a47eb4c |
Dawsh |
2y ago |
python3 main.py |
| 195 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 196 |
a47eb4c |
Dawsh |
2y ago |
|
| 197 |
bf00248 |
Dawsh |
2y ago |
To launch with linux systemctl (copy marzneshin.service file to `/var/lib/marzneshin/marzneshin.service`) |
| 198 |
a47eb4c |
Dawsh |
2y ago |
|
| 199 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 200 |
bf00248 |
Dawsh |
2y ago |
systemctl enable /var/lib/marzneshin/marzneshin.service |
| 201 |
bf00248 |
Dawsh |
2y ago |
systemctl start marzneshin |
| 202 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 203 |
a47eb4c |
Dawsh |
2y ago |
|
| 204 |
a47eb4c |
Dawsh |
2y ago |
To use with nginx |
| 205 |
a47eb4c |
Dawsh |
2y ago |
|
| 206 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 207 |
a47eb4c |
Dawsh |
2y ago |
server { |
| 208 |
a47eb4c |
Dawsh |
2y ago |
listen 443 ssl http2; |
| 209 |
a47eb4c |
Dawsh |
2y ago |
listen [::]:443 ssl http2; |
| 210 |
a47eb4c |
Dawsh |
2y ago |
server_name example.com; |
| 211 |
a47eb4c |
Dawsh |
2y ago |
|
| 212 |
a47eb4c |
Dawsh |
2y ago |
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; |
| 213 |
a47eb4c |
Dawsh |
2y ago |
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; |
| 214 |
a47eb4c |
Dawsh |
2y ago |
|
| 215 |
ece2ed6 |
Dawsh |
2y ago |
location ~* /(dashboard|static|locales|api|docs|redoc|openapi.json) { |
| 216 |
a47eb4c |
Dawsh |
2y ago |
proxy_pass http://0.0.0.0:8000; |
| 217 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header Host $host; |
| 218 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header X-Real-IP $remote_addr; |
| 219 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 220 |
a47eb4c |
Dawsh |
2y ago |
} |
| 221 |
a47eb4c |
Dawsh |
2y ago |
|
| 222 |
a47eb4c |
Dawsh |
2y ago |
# xray-core ws-path: / |
| 223 |
bf00248 |
Dawsh |
2y ago |
# client ws-path: /marzneshin/me/2087 |
| 224 |
a47eb4c |
Dawsh |
2y ago |
# |
| 225 |
a47eb4c |
Dawsh |
2y ago |
# All traffic is proxed through port 443, and send to the xray port(2087, 2088 etc.). |
| 226 |
bf00248 |
Dawsh |
2y ago |
# The '/marzneshin' in location regex path can changed any characters by yourself. |
| 227 |
a47eb4c |
Dawsh |
2y ago |
# |
| 228 |
a47eb4c |
Dawsh |
2y ago |
# /${path}/${username}/${xray-port} |
| 229 |
bf00248 |
Dawsh |
2y ago |
location ~* /marzneshin/.+/(.+)$ { |
| 230 |
a47eb4c |
Dawsh |
2y ago |
proxy_redirect off; |
| 231 |
a47eb4c |
Dawsh |
2y ago |
proxy_pass http://127.0.0.1:$1/; |
| 232 |
a47eb4c |
Dawsh |
2y ago |
proxy_http_version 1.1; |
| 233 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header Upgrade $http_upgrade; |
| 234 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header Connection "upgrade"; |
| 235 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header Host $http_host; |
| 236 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header X-Real-IP $remote_addr; |
| 237 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 238 |
a47eb4c |
Dawsh |
2y ago |
} |
| 239 |
a47eb4c |
Dawsh |
2y ago |
} |
| 240 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 241 |
a47eb4c |
Dawsh |
2y ago |
|
| 242 |
a47eb4c |
Dawsh |
2y ago |
or |
| 243 |
a47eb4c |
Dawsh |
2y ago |
|
| 244 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 245 |
a47eb4c |
Dawsh |
2y ago |
server { |
| 246 |
a47eb4c |
Dawsh |
2y ago |
listen 443 ssl http2; |
| 247 |
a47eb4c |
Dawsh |
2y ago |
listen [::]:443 ssl http2; |
| 248 |
bf00248 |
Dawsh |
2y ago |
server_name marzneshin.example.com; |
| 249 |
a47eb4c |
Dawsh |
2y ago |
|
| 250 |
a47eb4c |
Dawsh |
2y ago |
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; |
| 251 |
a47eb4c |
Dawsh |
2y ago |
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; |
| 252 |
a47eb4c |
Dawsh |
2y ago |
|
| 253 |
a47eb4c |
Dawsh |
2y ago |
location / { |
| 254 |
a47eb4c |
Dawsh |
2y ago |
proxy_pass http://0.0.0.0:8000; |
| 255 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header Host $host; |
| 256 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header X-Real-IP $remote_addr; |
| 257 |
a47eb4c |
Dawsh |
2y ago |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 258 |
a47eb4c |
Dawsh |
2y ago |
} |
| 259 |
a47eb4c |
Dawsh |
2y ago |
} |
| 260 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 261 |
a47eb4c |
Dawsh |
2y ago |
|
| 262 |
5c78ce8 |
Dawsh |
2y ago |
By default the app will be run on `http://localhost:8000/dashboard`. You can configure it using changing |
| 263 |
5c78ce8 |
Dawsh |
2y ago |
the `UVICORN_HOST` and `UVICORN_PORT` environment variables. |
| 264 |
a47eb4c |
Dawsh |
2y ago |
</details> |
| 265 |
a47eb4c |
Dawsh |
2y ago |
|
| 266 |
a47eb4c |
Dawsh |
2y ago |
# Configuration |
| 267 |
a47eb4c |
Dawsh |
2y ago |
|
| 268 |
a47eb4c |
Dawsh |
2y ago |
> You can set settings below using environment variables or placing them in `.env` file. |
| 269 |
a47eb4c |
Dawsh |
2y ago |
|
| 270 |
a47eb4c |
Dawsh |
2y ago |
| Variable | Description | |
| 271 |
5c78ce8 |
Dawsh |
2y ago |
|-----------------------------------|-------------------------------------------------------------------------------------------------------| |
| 272 |
a47eb4c |
Dawsh |
2y ago |
| SQLALCHEMY_DATABASE_URL | Database URL ([SQLAlchemy's docs](https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls)) | |
| 273 |
a47eb4c |
Dawsh |
2y ago |
| UVICORN_HOST | Bind application to this host (default: `0.0.0.0`) | |
| 274 |
a47eb4c |
Dawsh |
2y ago |
| UVICORN_PORT | Bind application to this port (default: `8000`) | |
| 275 |
a47eb4c |
Dawsh |
2y ago |
| UVICORN_UDS | Bind application to a UNIX domain socket | |
| 276 |
a47eb4c |
Dawsh |
2y ago |
| UVICORN_SSL_CERTFILE | SSL certificate file to have application on https | |
| 277 |
a47eb4c |
Dawsh |
2y ago |
| UVICORN_SSL_KEYFILE | SSL key file to have application on https | |
| 278 |
5c78ce8 |
Dawsh |
2y ago |
| SUBSCRIPTION_URL_PREFIX | Prefix of subscription URLs | |
| 279 |
a47eb4c |
Dawsh |
2y ago |
| CUSTOM_TEMPLATES_DIRECTORY | Customized templates directory (default: `app/templates`) | |
| 280 |
a47eb4c |
Dawsh |
2y ago |
| CLASH_SUBSCRIPTION_TEMPLATE | The template that will be used for generating clash configs (default: `clash/default.yml`) | |
| 281 |
a47eb4c |
Dawsh |
2y ago |
| SUBSCRIPTION_PAGE_TEMPLATE | The template used for generating subscription info page (default: `subscription/index.html`) | |
| 282 |
a47eb4c |
Dawsh |
2y ago |
| HOME_PAGE_TEMPLATE | Decoy page template (default: `home/index.html`) | |
| 283 |
a47eb4c |
Dawsh |
2y ago |
| TELEGRAM_API_TOKEN | Telegram bot API token (get token from [@botfather](https://t.me/botfather)) | |
| 284 |
a47eb4c |
Dawsh |
2y ago |
| TELEGRAM_ADMIN_ID | Numeric Telegram ID of admin (use [@userinfobot](https://t.me/userinfobot) to found your ID) | |
| 285 |
a47eb4c |
Dawsh |
2y ago |
| TELEGRAM_PROXY_URL | Run Telegram Bot over proxy | |
| 286 |
a47eb4c |
Dawsh |
2y ago |
| JWT_ACCESS_TOKEN_EXPIRE_MINUTES | Expire time for the Access Tokens in minutes, `0` considered as infinite (default: `1440`) | |
| 287 |
a47eb4c |
Dawsh |
2y ago |
| DOCS | Whether API documents should be available on `/docs` and `/redoc` or not (default: `False`) | |
| 288 |
a47eb4c |
Dawsh |
2y ago |
| DEBUG | Debug mode for development (default: `False`) | |
| 289 |
a47eb4c |
Dawsh |
2y ago |
| WEBHOOK_ADDRESS | Webhook address to send notifications to. Webhook notifications will be sent if this value was set. | |
| 290 |
a47eb4c |
Dawsh |
2y ago |
| WEBHOOK_SECRET | Webhook secret will be sent with each request as `x-webhook-secret` in the header (default: `None`) | |
| 291 |
a47eb4c |
Dawsh |
2y ago |
| NUMBER_OF_RECURRENT_NOTIFICATIONS | How many times to retry if an error detected in sending a notification (default: `3`) | |
| 292 |
a47eb4c |
Dawsh |
2y ago |
| RECURRENT_NOTIFICATIONS_TIMEOUT | Timeout between each retry if an error detected in sending a notification in seconds (default: `180`) | |
| 293 |
a47eb4c |
Dawsh |
2y ago |
| NOTIFY_REACHED_USAGE_PERCENT | At which percentage of usage to send the warning notification (default: `80`) | |
| 294 |
a47eb4c |
Dawsh |
2y ago |
| NOTIFY_DAYS_LEFT | When to send warning notifaction about expiration (default: `3`) | |
| 295 |
a47eb4c |
Dawsh |
2y ago |
|
| 296 |
a47eb4c |
Dawsh |
2y ago |
# API |
| 297 |
a47eb4c |
Dawsh |
2y ago |
|
| 298 |
5c78ce8 |
Dawsh |
2y ago |
Marzneshin provides a REST API that enables developers to interact with Marzneshin services programmatically. To view |
| 299 |
5c78ce8 |
Dawsh |
2y ago |
the API documentation in Swagger UI or ReDoc, set the configuration variable `DOCS=True` and navigate to the `/docs` |
| 300 |
5c78ce8 |
Dawsh |
2y ago |
and `/redoc`. |
| 301 |
a47eb4c |
Dawsh |
2y ago |
|
| 302 |
a47eb4c |
Dawsh |
2y ago |
# Backup |
| 303 |
a47eb4c |
Dawsh |
2y ago |
|
| 304 |
5c78ce8 |
Dawsh |
2y ago |
It's always a good idea to backup your Marzneshin files regularly to prevent data loss in case of system failures or |
| 305 |
5c78ce8 |
Dawsh |
2y ago |
accidental deletion. Here are the steps to backup Marzneshin: |
| 306 |
a47eb4c |
Dawsh |
2y ago |
|
| 307 |
5c78ce8 |
Dawsh |
2y ago |
1. By default, all Marzneshin important files are saved in `/var/lib/marzneshin` (Docker versions). Copy the |
| 308 |
5c78ce8 |
Dawsh |
2y ago |
entire `/var/lib/marzneshin` directory to a backup location of your choice, such as an external hard drive or cloud |
| 309 |
5c78ce8 |
Dawsh |
2y ago |
storage. |
| 310 |
5c78ce8 |
Dawsh |
2y ago |
2. Additionally, make sure to backup your env file, which contains your configuration variables. If you installed |
| 311 |
5c78ce8 |
Dawsh |
2y ago |
Marzneshin using the script (recommended installation approach), the env and other configurations should be |
| 312 |
5c78ce8 |
Dawsh |
2y ago |
inside `/etc/opt/marzneshin/` directory. |
| 313 |
a47eb4c |
Dawsh |
2y ago |
|
| 314 |
5c78ce8 |
Dawsh |
2y ago |
By following these steps, you can ensure that you have a backup of all your Marzneshin files and data, as well as your |
| 315 |
5c78ce8 |
Dawsh |
2y ago |
configuration variables and Xray configuration, in case you need to restore them in the future. Remember to update your |
| 316 |
5c78ce8 |
Dawsh |
2y ago |
backups regularly to keep them up-to-date. |
| 317 |
a47eb4c |
Dawsh |
2y ago |
|
| 318 |
a47eb4c |
Dawsh |
2y ago |
# Telegram Bot |
| 319 |
a47eb4c |
Dawsh |
2y ago |
|
| 320 |
5c78ce8 |
Dawsh |
2y ago |
Marzneshin comes with an integrated Telegram bot that can handle server management, user creation and removal, and send |
| 321 |
5c78ce8 |
Dawsh |
2y ago |
notifications. This bot can be easily enabled by following a few simple steps, and it provides a convenient way to |
| 322 |
5c78ce8 |
Dawsh |
2y ago |
interact with Marzneshin without having to log in to the server every time. |
| 323 |
a47eb4c |
Dawsh |
2y ago |
|
| 324 |
a47eb4c |
Dawsh |
2y ago |
To enable Telegram Bot: |
| 325 |
a47eb4c |
Dawsh |
2y ago |
|
| 326 |
a47eb4c |
Dawsh |
2y ago |
1. set `TELEGRAM_API_TOKEN` to your bot's API Token |
| 327 |
5c78ce8 |
Dawsh |
2y ago |
2. set `TELEGRAM_ADMIN_ID` to your Telegram account's numeric ID, you can get your ID |
| 328 |
5c78ce8 |
Dawsh |
2y ago |
from [@userinfobot](https://t.me/userinfobot) |
| 329 |
a47eb4c |
Dawsh |
2y ago |
|
| 330 |
bf00248 |
Dawsh |
2y ago |
# Marzneshin CLI |
| 331 |
a47eb4c |
Dawsh |
2y ago |
|
| 332 |
5c78ce8 |
Dawsh |
2y ago |
Marzneshin comes with an integrated CLI named `marzneshin-cli` which allows administrators to have direct interaction |
| 333 |
5c78ce8 |
Dawsh |
2y ago |
with it. |
| 334 |
a47eb4c |
Dawsh |
2y ago |
|
| 335 |
bf00248 |
Dawsh |
2y ago |
If you've installed Marzneshin using the installation script, you can access the cli commands by running |
| 336 |
a47eb4c |
Dawsh |
2y ago |
|
| 337 |
a47eb4c |
Dawsh |
2y ago |
```bash |
| 338 |
bf00248 |
Dawsh |
2y ago |
marzneshin cli [OPTIONS] COMMAND [ARGS]... |
| 339 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 340 |
a47eb4c |
Dawsh |
2y ago |
|
| 341 |
bf00248 |
Dawsh |
2y ago |
For more information, You can read [Marzneshin CLI's documentation](./cli/README.md). |
| 342 |
a47eb4c |
Dawsh |
2y ago |
|
| 343 |
bf00248 |
Dawsh |
2y ago |
# marznode |
| 344 |
a47eb4c |
Dawsh |
2y ago |
|
| 345 |
bf00248 |
Dawsh |
2y ago |
[marznode](https://github.com/khodedawsh/marznode) is the backend needed to run proxy servers. |
| 346 |
a47eb4c |
Dawsh |
2y ago |
|
| 347 |
a47eb4c |
Dawsh |
2y ago |
# Webhook notifications |
| 348 |
a47eb4c |
Dawsh |
2y ago |
|
| 349 |
bf00248 |
Dawsh |
2y ago |
You can set a webhook address and Marzneshin will send the notifications to that address. |
| 350 |
a47eb4c |
Dawsh |
2y ago |
|
| 351 |
5c78ce8 |
Dawsh |
2y ago |
the requests will be sent as a post request to the adress provided by `WEBHOOK_ADDRESS` with `WEBHOOK_SECRET` |
| 352 |
5c78ce8 |
Dawsh |
2y ago |
as `x-webhook-secret` in the headers. |
| 353 |
a47eb4c |
Dawsh |
2y ago |
|
| 354 |
bf00248 |
Dawsh |
2y ago |
Example request sent from Marzneshin: |
| 355 |
a47eb4c |
Dawsh |
2y ago |
|
| 356 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 357 |
a47eb4c |
Dawsh |
2y ago |
Headers: |
| 358 |
a47eb4c |
Dawsh |
2y ago |
Host: 0.0.0.0:9000 |
| 359 |
a47eb4c |
Dawsh |
2y ago |
User-Agent: python-requests/2.28.1 |
| 360 |
a47eb4c |
Dawsh |
2y ago |
Accept-Encoding: gzip, deflate |
| 361 |
a47eb4c |
Dawsh |
2y ago |
Accept: */* |
| 362 |
a47eb4c |
Dawsh |
2y ago |
Connection: keep-alive |
| 363 |
a47eb4c |
Dawsh |
2y ago |
x-webhook-secret: something-very-very-secret |
| 364 |
a47eb4c |
Dawsh |
2y ago |
Content-Length: 107 |
| 365 |
a47eb4c |
Dawsh |
2y ago |
Content-Type: application/json |
| 366 |
a47eb4c |
Dawsh |
2y ago |
|
| 367 |
a47eb4c |
Dawsh |
2y ago |
|
| 368 |
a47eb4c |
Dawsh |
2y ago |
|
| 369 |
a47eb4c |
Dawsh |
2y ago |
Body: |
| 370 |
bf00248 |
Dawsh |
2y ago |
{"username": "marzneshin_test_user", "action": "user_updated", "enqueued_at": 1680506457.636369, "tries": 0} |
| 371 |
a47eb4c |
Dawsh |
2y ago |
``` |
| 372 |
a47eb4c |
Dawsh |
2y ago |
|
| 373 |
5c78ce8 |
Dawsh |
2y ago |
Different action typs |
| 374 |
5c78ce8 |
Dawsh |
2y ago |
are: `user_created`, `user_updated`, `user_deleted`, `user_limited`, `user_expired`, `user_disabled`, `user_enabled` |
| 375 |
a47eb4c |
Dawsh |
2y ago |
|
| 376 |
a47eb4c |
Dawsh |
2y ago |
# Donation |
| 377 |
a47eb4c |
Dawsh |
2y ago |
|
| 378 |
5c78ce8 |
Dawsh |
2y ago |
If you found Marzneshin useful and would like to support its development, you can make a donation in one of the |
| 379 |
5c78ce8 |
Dawsh |
2y ago |
following crypto networks: |
| 380 |
bfd37dd |
Mrdn |
2y ago |
|
| 381 |
bfd37dd |
Mrdn |
2y ago |
- Bitcoin network: 13ZDhE5KHGsfjM4A22eLTUgW98WpXhQTuF |
| 382 |
bfd37dd |
Mrdn |
2y ago |
- TRON network (TRC20): TYxFCiRqJ3SiV6rAQAmJUd3DgVmJvEAfz4 |
| 383 |
bfd37dd |
Mrdn |
2y ago |
- TON network: EQB_VYiU73U1_wk-01I_MLg9-hx953VOf9Y36t2Z04WyUapD |
| 384 |
a47eb4c |
Dawsh |
2y ago |
|
| 385 |
bfd37dd |
Mrdn |
2y ago |
Part of the donations would be tipped to contributors, the rest to collaborators. |
| 386 |
a47eb4c |
Dawsh |
2y ago |
|
| 387 |
bfd37dd |
Mrdn |
2y ago |
May developers be rich. |
| 388 |
a47eb4c |
Dawsh |
2y ago |
|
| 389 |
a47eb4c |
Dawsh |
2y ago |
# License |
| 390 |
a47eb4c |
Dawsh |
2y ago |
|
| 391 |
bfd37dd |
Mrdn |
2y ago |
Published under [AGPL-3.0](./LICENSE). |
| 392 |
a47eb4c |
Dawsh |
2y ago |
|
| 393 |
a47eb4c |
Dawsh |
2y ago |
# Contributors |
| 394 |
a47eb4c |
Dawsh |
2y ago |
|
| 395 |
5c78ce8 |
Dawsh |
2y ago |
We ❤️🔥 contributors! If you'd like to contribute, please check out our [Contributing Guidelines](CONTRIBUTING.md) and |
| 396 |
5c78ce8 |
Dawsh |
2y ago |
feel free to submit a pull request or open an issue. We also welcome you to join |
| 397 |
5c78ce8 |
Dawsh |
2y ago |
our [Telegram](https://t.me/marzneshins) group for either support or contributing guidance. |
| 398 |
a47eb4c |
Dawsh |
2y ago |
|
| 399 |
bf00248 |
Dawsh |
2y ago |
Check [open issues](https://github.com/khodedawsh/marzneshin/issues) to help the progress of this project. |
| 400 |
a47eb4c |
Dawsh |
2y ago |
|
| 401 |
a47eb4c |
Dawsh |
2y ago |
<p align="center"> |
| 402 |
bfd37dd |
Mrdn |
2y ago |
Thanks to all contributors who have helped Marzneshin: |
| 403 |
a47eb4c |
Dawsh |
2y ago |
</p> |
| 404 |
bf00248 |
Dawsh |
2y ago |
<p align="center"> |
| 405 |
bf00248 |
Dawsh |
2y ago |
<a href="https://github.com/khodedawsh/marzneshin/graphs/contributors"> |
| 406 |
bf00248 |
Dawsh |
2y ago |
<img src="https://contrib.rocks/image?repo=khodedawsh/marzneshin" /> |
| 407 |
bf00248 |
Dawsh |
2y ago |
</a> |
| 408 |
bf00248 |
Dawsh |
2y ago |
</p> |
| 409 |
a47eb4c |
Dawsh |
2y ago |
<p align="center"> |
| 410 |
a47eb4c |
Dawsh |
2y ago |
Made with <a rel="noopener noreferrer" target="_blank" href="https://contrib.rocks">contrib.rocks</a> |
| 411 |
a47eb4c |
Dawsh |
2y ago |
</p> |