Skip to content

Commit

Permalink
docs: migrating existing documents to docs.marzneshin.org
Browse files Browse the repository at this point in the history
  • Loading branch information
Krr0ptioN committed Jul 30, 2024
1 parent 12c9fb2 commit 204bf97
Show file tree
Hide file tree
Showing 8 changed files with 629 additions and 0 deletions.
78 changes: 78 additions & 0 deletions content/docs/configuration/marzneshin.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,81 @@
---
title: Marzneshin
---

> You can set settings below using environment variables or placing them in `.env` file.
## Basic

| Variable | Description |
| ------------------------------- | ----------------------------------------------------------------------------------------------------- |
| UVICORN_HOST | Bind application to this host (default: `0.0.0.0`) |
| UVICORN_PORT | Bind application to this port (default: `8000`) |
| UVICORN_UDS | Bind application to a UNIX domain socket |
| UVICORN_SSL_CERTFILE | SSL certificate file to have application on https |
| UVICORN_SSL_KEYFILE | SSL key file to have application on https |
| SQLALCHEMY_DATABASE_URL | Database URL ([SQLAlchemy's docs](https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls)) |
| JWT_ACCESS_TOKEN_EXPIRE_MINUTES | Expire time for the Access Tokens in minutes, `0` considered as infinite (default: `1440`) |

## Subscription and VPN customization

| Variable | Description |
| --------------------------- | -------------------------------------------------------------------------------------------- |
| CUSTOM_TEMPLATES_DIRECTORY | Customized templates directory (default: `app/templates`) |
| CLASH_SUBSCRIPTION_TEMPLATE | The template that will be used for generating clash configs (default: `clash/default.yml`) |
| SUBSCRIPTION_PAGE_TEMPLATE | The template used for generating subscription info page (default: `subscription/index.html`) |
| SUBSCRIPTION_URL_PREFIX | Prefix of subscription URLs |
| HOME_PAGE_TEMPLATE | Decoy page template (default: `home/index.html`) |

## Telegram

| Variable | Description |
| ------------------ | -------------------------------------------------------------------------------------------- |
| TELEGRAM_API_TOKEN | Telegram bot API token (get token from [@botfather](https://t.me/botfather)) |
| TELEGRAM_ADMIN_ID | Numeric Telegram ID of admin (use [@userinfobot](https://t.me/userinfobot) to found your ID) |
| TELEGRAM_PROXY_URL | Run Telegram Bot over proxy |

## Notification & Webhook

| Variable | Description |
| --------------------------------- | ----------------------------------------------------------------------------------------------------- |
| WEBHOOK_ADDRESS | Webhook address to send notifications to. Webhook notifications will be sent if this value was set. |
| WEBHOOK_SECRET | Webhook secret will be sent with each request as `x-webhook-secret` in the header (default: `None`) |
| NUMBER_OF_RECURRENT_NOTIFICATIONS | How many times to retry if an error detected in sending a notification (default: `3`) |
| RECURRENT_NOTIFICATIONS_TIMEOUT | Timeout between each retry if an error detected in sending a notification in seconds (default: `180`) |
| NOTIFY_REACHED_USAGE_PERCENT | At which percentage of usage to send the warning notification (default: `80`) |
| NOTIFY_DAYS_LEFT | When to send warning notification about expiration (default: `3`) |

## Development and Documentation

| Variable | Description |
| -------- | ------------------------------------------------------------------------------------------- |
| DOCS | Whether API documents should be available on `/docs` and `/redoc` or not (default: `False`) |
| DEBUG | Debug mode for development (default: `False`) |

## .env File Example

```sh
SQLALCHEMY_DATABASE_URL=
UVICORN_HOST=
UVICORN_PORT=
UVICORN_UDS=
UVICORN_SSL_CERTFILE=
UVICORN_SSL_KEYFILE=
SUBSCRIPTION_URL_PREFIX=
CUSTOM_TEMPLATES_DIRECTORY=
CLASH_SUBSCRIPTION_TEMPLATE=
SUBSCRIPTION_PAGE_TEMPLATE=
HOME_PAGE_TEMPLATE=
TELEGRAM_API_TOKEN=
TELEGRAM_ADMIN_ID=
TELEGRAM_PROXY_URL=
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=
DOCS=true
DEBUG=true
WEBHOOK_ADDRESS="http://localhost:9000"
WEBHOOK_SECRET="dont-tell-anybody"
NUMBER_OF_RECURRENT_NOTIFICATIONS=
RECURRENT_NOTIFICATIONS_TIMEOUT=
NOTIFY_REACHED_USAGE_PERCENT=
NOTIFY_DAYS_LEFT=
```
7 changes: 7 additions & 0 deletions content/docs/contribution-guideline/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "API"
---

Marzneshin provides a REST API that enables developers to interact with Marzneshin
services programmatically. To view the API documentation in Swagger UI or ReDoc, set
the configuration variable `DOCS=True` and navigate to the `/docs` and `/redoc`.
16 changes: 16 additions & 0 deletions content/docs/contribution-guideline/support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "Support"
---

# Donation

If you found Marzneshin useful and would like to support its development, you can make a donation in one of the
following crypto networks:

- Bitcoin network: 13ZDhE5KHGsfjM4A22eLTUgW98WpXhQTuF
- TRON network (TRC20): TYxFCiRqJ3SiV6rAQAmJUd3DgVmJvEAfz4
- TON network: EQB_VYiU73U1_wk-01I_MLg9-hx953VOf9Y36t2Z04WyUapD

Part of the donations would be tipped to contributors, the rest to collaborators.

May developers be rich.
159 changes: 159 additions & 0 deletions content/docs/getting-started/installation/marzneshin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,162 @@
title: Installing Marzneshin
weight: 1
---

Run the following command

```bash
sudo bash -c "$(curl -sL https://github.com/khodedawsh/Marzneshin/raw/master/script.sh)" @ install
```

To install with mariadb:

```bash
sudo bash -c "$(curl -sL https://github.com/khodedawsh/Marzneshin/raw/master/script.sh)" @ install --database mariadb
```

You could also use mysql by writing mysql instead, however mariadb is **recommended**.
Also to install the latest nightly release use the `--nightly` option.

Once the installation is complete:

- You'd notice the logs, which you could stop watching by pressing `Ctrl+C`; The process will continue running normally.
- the configuration file can be found at `/etc/opt/marzneshin/.env` (refer to [configurations](#configuration) section
to see variables)
- Data files will be placed at `/var/lib/marzneshin`; e.g. the sqlite database.
- You can access the Marzneshin dashboard by opening a web browser and navigating
to `http://<SERVER_IP>:8000/dashboard/`

Next, you need to create a sudo admin for logging into the Marzneshin dashboard by the following command

```bash
marzneshin cli admin create --sudo
```

That's it! You can login to your dashboard using these credentials

To see the help message of the Marzneshin script, run the following command

```bash
marzneshin --help
```

If you are eager to run the project using the source code, check the section below

<details markdown="1">
<summary><h3>Manual install (advanced)</h3></summary>

Clone this project and install the dependencies (you'd need Python >= 3.10)

```bash
git clone https://github.com/khodedawsh/Marzneshin
cd Marzneshin/
wget -qO- https://bootstrap.pypa.io/get-pip.py | python3 -
python3 -m pip install -r requirements.txt
```

Alternatively, to have an isolated environment you can use [Python Virtualenv](https://pypi.org/project/virtualenv/)

To install dashboard dependencies and build the dashboard:

```bash
make dashboard-deps
make dashboard-build
```

note that you'll need pnpm and npm installed.

If you want to use `marzneshin-cli`, you should link it to a file in your `$PATH`, make it executable, and install the
auto-completion:

```bash
sudo ln -s $(pwd)/marzneshin-cli.py /usr/bin/marzneshin-cli
sudo chmod +x /usr/bin/marzneshin-cli
marzneshin-cli completion install
```

Now it's time to configuration

Make a copy of `.env.example` file, take a look and edit it using a text editor like `nano`.

```bash
cp .env.example .env
nano .env
```

> Check [marzneshin configuration](docs/configuration/marzneshin) guide for more information
Eventually, launch the application using command below

```bash
make start
```

To launch with linux systemctl (copy marzneshin.service file to `/var/lib/marzneshin/marzneshin.service`)

```
systemctl enable /var/lib/marzneshin/marzneshin.service
systemctl start marzneshin
```

To use with nginx

```
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location ~* /(dashboard|static|locales|api|docs|redoc|openapi.json) {
proxy_pass http://0.0.0.0:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# xray-core ws-path: /
# client ws-path: /marzneshin/me/2087
#
# All traffic is proxed through port 443, and send to the xray port(2087, 2088 etc.).
# The '/marzneshin' in location regex path can changed any characters by yourself.
#
# /${path}/${username}/${xray-port}
location ~* /marzneshin/.+/(.+)$ {
proxy_redirect off;
proxy_pass http://127.0.0.1:$1/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```

or

```
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name marzneshin.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
proxy_pass http://0.0.0.0:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```

By default the app will be run on `http://localhost:8000/dashboard`. You can configure it using changing
the `UVICORN_HOST` and `UVICORN_PORT` environment variables.

</details>
17 changes: 17 additions & 0 deletions content/docs/how-to-guides/backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "Backup"
---

It's always a good idea to backup your Marzneshin files regularly to prevent data loss in case of system failures or
accidental deletion. Here are the steps to backup Marzneshin:

1. By default, all Marzneshin important files are saved in `/var/lib/marzneshin` (Docker versions). Copy the
entire `/var/lib/marzneshin` directory to a backup location of your choice, such as an external hard drive or cloud
storage.
2. Additionally, make sure to backup your env file, which contains your configuration variables. If you installed
Marzneshin using the script (recommended installation approach), the env and other configurations should be
inside `/etc/opt/marzneshin/` directory.

By following these steps, you can ensure that you have a backup of all your Marzneshin files and data, as well as your
configuration variables and Xray configuration, in case you need to restore them in the future. Remember to update your
backups regularly to keep them up-to-date.
Loading

0 comments on commit 204bf97

Please sign in to comment.