forked from test2/Amnezia-Web-Panel-main
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d62758716 | ||
|
|
d26843a0d1 | ||
|
|
706d2c9c0d | ||
|
|
2746f981af | ||
|
|
4f5a1d7554 |
+10
-3
@@ -2,11 +2,18 @@
|
|||||||
APP_PORT=5000
|
APP_PORT=5000
|
||||||
SECRET_KEY=change-me-to-a-long-random-string
|
SECRET_KEY=change-me-to-a-long-random-string
|
||||||
|
|
||||||
# PostgreSQL (used by docker-compose)
|
# PostgreSQL (docker-compose — same password for db + panel via DATABASE_URL)
|
||||||
POSTGRES_USER=amnezia
|
POSTGRES_USER=amnezia
|
||||||
POSTGRES_PASSWORD=amnezia
|
POSTGRES_PASSWORD=change-me-strong-password
|
||||||
POSTGRES_DB=amnezia_panel
|
POSTGRES_DB=amnezia_panel
|
||||||
POSTGRES_PORT=5432
|
POSTGRES_PORT=5432
|
||||||
|
|
||||||
|
# Set once before first deploy. Changing POSTGRES_PASSWORD later requires resetting
|
||||||
|
# the amnezia_pgdata volume or the panel cannot connect (Postgres keeps the old password).
|
||||||
|
|
||||||
# Full DSN (override if panel runs outside compose)
|
# Full DSN (override if panel runs outside compose)
|
||||||
# DATABASE_URL=postgresql://amnezia:amnezia@db:5432/amnezia_panel
|
# DATABASE_URL=postgresql://amnezia:change-me-strong-password@db:5432/amnezia_panel
|
||||||
|
|
||||||
|
# Dokploy / reverse proxy (optional — set in compose for Docker)
|
||||||
|
# PANEL_IN_DOCKER=1
|
||||||
|
# PANEL_BEHIND_PROXY=1
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
*.sh text eol=lf
|
||||||
+5
-3
@@ -5,7 +5,9 @@ FROM python:3.12-slim
|
|||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
APP_PORT=5000 \
|
APP_PORT=5000 \
|
||||||
|
PORT=5000 \
|
||||||
PANEL_IN_DOCKER=1 \
|
PANEL_IN_DOCKER=1 \
|
||||||
|
PANEL_BEHIND_PROXY=1 \
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -21,7 +23,7 @@ COPY . .
|
|||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||||
CMD curl -fsS "http://127.0.0.1:${APP_PORT}/health" >/dev/null || exit 1
|
CMD curl -fsS "http://127.0.0.1:5000/health" >/dev/null || exit 1
|
||||||
|
|
||||||
CMD ["python3", "app.py"]
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "5000", "--proxy-headers", "--forwarded-allow-ips", "*"]
|
||||||
|
|||||||
@@ -188,22 +188,71 @@ Mac
|
|||||||
```bash
|
```bash
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
# set SECRET_KEY and strong POSTGRES_PASSWORD in .env
|
# set SECRET_KEY and strong POSTGRES_PASSWORD in .env
|
||||||
|
docker network inspect dokploy-network >/dev/null 2>&1 || docker network create dokploy-network
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
Panel: `http://localhost:5000` (or `APP_PORT` from `.env`).
|
Panel: `http://localhost:5000` (or `APP_PORT` from `.env`).
|
||||||
|
|
||||||
|
### Dokploy (recommended)
|
||||||
|
|
||||||
|
The compose file connects the panel to Dokploy's Traefik network (`dokploy-network`) and exposes the app on **container port 5000** (not 80).
|
||||||
|
|
||||||
|
1. Deploy as **Docker Compose** from this repo (Dokploy creates `dokploy-network` automatically).
|
||||||
|
2. In Dokploy → your app → **Environment** (set **before first deploy**):
|
||||||
|
- `SECRET_KEY` — long random string
|
||||||
|
- `POSTGRES_PASSWORD` — strong password (same value is used for `db` and `amnezia_panel`)
|
||||||
|
3. In Dokploy → **Domains**:
|
||||||
|
- **Service**: `amnezia_panel` (not `db`)
|
||||||
|
- **Container port**: `5000`
|
||||||
|
- **Path**: `/`
|
||||||
|
4. **Deploy / Rebuild** (not Restart) after code or env changes.
|
||||||
|
|
||||||
|
**Verify on the server** (replace `PROJECT` and path with yours):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
COMPOSE_DIR=/etc/dokploy/compose/home-vpn-g6rfpd/code
|
||||||
|
PROJECT=home-vpn-g6rfpd
|
||||||
|
|
||||||
|
docker compose -p $PROJECT -f $COMPOSE_DIR/docker-compose.yml exec amnezia_panel \
|
||||||
|
curl -fsS http://127.0.0.1:5000/health
|
||||||
|
# → {"status":"ok","version":"v2.6.0"}
|
||||||
|
|
||||||
|
docker inspect ${PROJECT}-amnezia_panel-1 \
|
||||||
|
--format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}} {{end}}'
|
||||||
|
# must include: dokploy-network
|
||||||
|
```
|
||||||
|
|
||||||
|
**Full redeploy after git update:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd $COMPOSE_DIR && git pull origin main
|
||||||
|
docker compose -p $PROJECT -f $COMPOSE_DIR/docker-compose.yml down
|
||||||
|
docker compose -p $PROJECT -f $COMPOSE_DIR/docker-compose.yml build --no-cache amnezia_panel
|
||||||
|
docker compose -p $PROJECT -f $COMPOSE_DIR/docker-compose.yml up -d --force-recreate
|
||||||
|
```
|
||||||
|
|
||||||
|
**Postgres `password authentication failed`:** the volume keeps the password from the **first** deploy. If you change `POSTGRES_PASSWORD` in Dokploy later, reset the DB volume (wipes panel DB data):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose -p $PROJECT -f $COMPOSE_DIR/docker-compose.yml down
|
||||||
|
docker volume rm ${PROJECT}_amnezia_pgdata
|
||||||
|
docker compose -p $PROJECT -f $COMPOSE_DIR/docker-compose.yml up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
**Domain shows `404 page not found` (plain text):** Traefik has no route to the panel — check Domains (service `amnezia_panel`, port `5000`) and that the container is on `dokploy-network` (see verify commands above).
|
||||||
|
|
||||||
| File | Purpose |
|
| File | Purpose |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `Dockerfile` | Production image (Python 3.12) |
|
| `Dockerfile` | Production image (Python 3.12) |
|
||||||
| `docker-compose.yml` | Panel + PostgreSQL with healthchecks |
|
| `docker-compose.yml` | Panel + PostgreSQL with healthchecks, Dokploy/Traefik labels |
|
||||||
| `.env.example` | Environment template |
|
| `.env.example` | Environment template |
|
||||||
|
|
||||||
**Environment**
|
**Environment**
|
||||||
|
|
||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `APP_PORT` | `5000` | Host port / in-container listen port |
|
| `APP_PORT` / `PORT` | `5000` | Host port / in-container listen port |
|
||||||
| `SECRET_KEY` | (random) | Session signing key — set in production |
|
| `SECRET_KEY` | (random) | Session signing key — set in production |
|
||||||
| `DATABASE_URL` | compose DSN | PostgreSQL connection string |
|
| `DATABASE_URL` | compose DSN | PostgreSQL connection string |
|
||||||
| `POSTGRES_*` | `amnezia` | DB credentials for the `db` service |
|
| `POSTGRES_*` | `amnezia` | DB credentials for the `db` service |
|
||||||
@@ -228,15 +277,37 @@ GitHub Actions workflows in `.github/workflows/`:
|
|||||||
|
|
||||||
## 📋 Fix / changelog (this fork)
|
## 📋 Fix / changelog (this fork)
|
||||||
|
|
||||||
|
### v2.6.1
|
||||||
|
* **Move connections between servers** — restored: select configs on a server page and move to another server (recreates peers, keeps user links). `ToggleConnectionRequest` kept intact.
|
||||||
|
|
||||||
|
### v2.6.0 — stable Dokploy / Docker release
|
||||||
|
* **Dokploy-ready compose** — `dokploy-network`, Traefik labels, port **5000**, no fixed `container_name`.
|
||||||
|
* **Docker startup** — `uvicorn` with proxy headers; SSL inside container disabled when `PANEL_IN_DOCKER` / `PANEL_BEHIND_PROXY`.
|
||||||
|
* **Postgres healthcheck** — verifies password (catches `POSTGRES_PASSWORD` vs volume mismatch).
|
||||||
|
* **Rollback move-connections** — removed server-to-server config move (v2.5.4); restored `ToggleConnectionRequest` (fixes crash loop on deploy).
|
||||||
|
* **Docs** — full Dokploy deploy/redeploy/password-reset guide in README.
|
||||||
|
|
||||||
|
### v2.5.11
|
||||||
|
* **Postgres healthcheck** — verifies DB password (surfaces `POSTGRES_PASSWORD` / volume mismatch before panel starts).
|
||||||
|
|
||||||
|
### v2.5.10
|
||||||
|
* **Docker startup** — run `uvicorn` directly in `CMD` (no shell entrypoint); rebuild required after deploy.
|
||||||
|
|
||||||
|
### v2.5.9
|
||||||
|
* **Remove move connections between servers** — feature rolled back; fixes startup crash (`ToggleConnectionRequest` was missing after v2.5.4).
|
||||||
|
|
||||||
|
### v2.5.8
|
||||||
|
* **Docker/Dokploy: panel actually serves HTTP** — entrypoint waits for Postgres, runs `uvicorn` with proxy headers; SSL inside the container is forced off when `PANEL_IN_DOCKER` / `PANEL_BEHIND_PROXY` is set (fixes empty replies on port 5000 behind Traefik).
|
||||||
|
|
||||||
|
### v2.5.7
|
||||||
|
* **Dokploy / Traefik 404 fix** — `docker-compose.yml` joins `dokploy-network`, Traefik labels point to port **5000**; removed fixed `container_name`; README Dokploy domain setup.
|
||||||
|
|
||||||
### v2.5.6
|
### v2.5.6
|
||||||
* **Fix 404 after in-panel update (no tunnel)** — safer Docker restart, validate update before restart, friendly 404 page with panel link.
|
* **Fix 404 after in-panel update (no tunnel)** — safer Docker restart, validate update before restart, friendly 404 page with panel link.
|
||||||
|
|
||||||
### v2.5.5
|
### v2.5.5
|
||||||
* **Fix 404 after panel update** — correct tunnel/local port when `APP_PORT` is set (Docker), health check before reload, auto-restart quick tunnels after reboot, reliable archive download URLs.
|
* **Fix 404 after panel update** — correct tunnel/local port when `APP_PORT` is set (Docker), health check before reload, auto-restart quick tunnels after reboot, reliable archive download URLs.
|
||||||
|
|
||||||
### v2.5.4
|
|
||||||
* **Move connections between servers** — on a server page, select configs and move them to another server (recreates peers, keeps user links).
|
|
||||||
|
|
||||||
### v2.5.3
|
### v2.5.3
|
||||||
* **Fix gray Update panel button** — enabled by default; Docker installs allow in-container archive updates when `/app` is writable.
|
* **Fix gray Update panel button** — enabled by default; Docker installs allow in-container archive updates when `/app` is writable.
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ else:
|
|||||||
application_path = os.path.dirname(__file__)
|
application_path = os.path.dirname(__file__)
|
||||||
|
|
||||||
DATA_FILE = os.path.join(application_path, 'data.json') # legacy JSON; used only for one-shot import / export
|
DATA_FILE = os.path.join(application_path, 'data.json') # legacy JSON; used only for one-shot import / export
|
||||||
CURRENT_VERSION = "v2.5.6"
|
CURRENT_VERSION = "v2.6.1"
|
||||||
RELEASES_REPO_URL = repo_url()
|
RELEASES_REPO_URL = repo_url()
|
||||||
RELEASES_API_LATEST = api_latest_url()
|
RELEASES_API_LATEST = api_latest_url()
|
||||||
BIN_DIR = os.environ.get('TUNNEL_BIN_DIR', os.path.join(application_path, 'bin'))
|
BIN_DIR = os.environ.get('TUNNEL_BIN_DIR', os.path.join(application_path, 'bin'))
|
||||||
@@ -226,12 +226,13 @@ def tpl(request, template, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def get_panel_listen_port(data: Optional[dict] = None) -> int:
|
def get_panel_listen_port(data: Optional[dict] = None) -> int:
|
||||||
try:
|
for env_key in ('APP_PORT', 'PORT'):
|
||||||
env_port = int(os.environ.get('APP_PORT', '0') or '0')
|
try:
|
||||||
except ValueError:
|
env_port = int(os.environ.get(env_key, '0') or '0')
|
||||||
env_port = 0
|
except ValueError:
|
||||||
if env_port:
|
env_port = 0
|
||||||
return env_port
|
if env_port:
|
||||||
|
return env_port
|
||||||
if data is None:
|
if data is None:
|
||||||
data = load_data()
|
data = load_data()
|
||||||
ssl_conf = data.get('settings', {}).get('ssl', {}) or {}
|
ssl_conf = data.get('settings', {}).get('ssl', {}) or {}
|
||||||
@@ -242,14 +243,16 @@ def get_panel_listen_port(data: Optional[dict] = None) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def panel_ssl_active(data: Optional[dict] = None) -> bool:
|
def panel_ssl_active(data: Optional[dict] = None) -> bool:
|
||||||
|
# Behind Docker / reverse proxy TLS is always terminated outside the app.
|
||||||
|
if os.environ.get('PANEL_IN_DOCKER') == '1' or os.environ.get('PANEL_BEHIND_PROXY') == '1':
|
||||||
|
return False
|
||||||
|
if os.environ.get('APP_PORT') or os.environ.get('PORT'):
|
||||||
|
return False
|
||||||
if data is None:
|
if data is None:
|
||||||
data = load_data()
|
data = load_data()
|
||||||
ssl_conf = data.get('settings', {}).get('ssl', {}) or {}
|
ssl_conf = data.get('settings', {}).get('ssl', {}) or {}
|
||||||
if not ssl_conf.get('enabled'):
|
if not ssl_conf.get('enabled'):
|
||||||
return False
|
return False
|
||||||
# Docker/compose usually terminates TLS outside the app and serves plain HTTP inside.
|
|
||||||
if os.environ.get('APP_PORT'):
|
|
||||||
return False
|
|
||||||
cert_path = ssl_conf.get('cert_path')
|
cert_path = ssl_conf.get('cert_path')
|
||||||
key_path = ssl_conf.get('key_path')
|
key_path = ssl_conf.get('key_path')
|
||||||
if ssl_conf.get('cert_text') or ssl_conf.get('key_text'):
|
if ssl_conf.get('cert_text') or ssl_conf.get('key_text'):
|
||||||
@@ -2191,6 +2194,12 @@ class ConnectionActionRequest(BaseModel):
|
|||||||
client_id: str = ''
|
client_id: str = ''
|
||||||
|
|
||||||
|
|
||||||
|
class ToggleConnectionRequest(BaseModel):
|
||||||
|
protocol: str = 'awg'
|
||||||
|
client_id: str = ''
|
||||||
|
enable: bool = True
|
||||||
|
|
||||||
|
|
||||||
class MoveConnectionsRequest(BaseModel):
|
class MoveConnectionsRequest(BaseModel):
|
||||||
protocol: str = 'awg'
|
protocol: str = 'awg'
|
||||||
target_server_id: int
|
target_server_id: int
|
||||||
@@ -6657,15 +6666,13 @@ if __name__ == '__main__':
|
|||||||
with open(key_file, 'w') as f:
|
with open(key_file, 'w') as f:
|
||||||
f.write(ssl_conf['key_text'].strip() + '\n')
|
f.write(ssl_conf['key_text'].strip() + '\n')
|
||||||
|
|
||||||
try:
|
port = get_panel_listen_port(data)
|
||||||
env_port = int(os.environ.get('APP_PORT', '0') or '0')
|
|
||||||
except ValueError:
|
|
||||||
env_port = 0
|
|
||||||
uvicorn_kwargs = {
|
uvicorn_kwargs = {
|
||||||
"app": app,
|
"app": app,
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"port": env_port or get_panel_listen_port(data),
|
"port": port,
|
||||||
}
|
}
|
||||||
|
logger.info(f"Amnezia Web Panel {CURRENT_VERSION} listening on http://0.0.0.0:{port}")
|
||||||
|
|
||||||
if panel_ssl_active(data) and cert_file and key_file:
|
if panel_ssl_active(data) and cert_file and key_file:
|
||||||
if os.path.exists(cert_file) and os.path.exists(key_file):
|
if os.path.exists(cert_file) and os.path.exists(key_file):
|
||||||
|
|||||||
+25
-6
@@ -1,18 +1,21 @@
|
|||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:17
|
image: postgres:17
|
||||||
container_name: amnezia_panel_db
|
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-amnezia}
|
POSTGRES_USER: ${POSTGRES_USER:-amnezia}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-amnezia}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-amnezia}
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-amnezia_panel}
|
POSTGRES_DB: ${POSTGRES_DB:-amnezia_panel}
|
||||||
volumes:
|
volumes:
|
||||||
- amnezia_pgdata:/var/lib/postgresql/data
|
- amnezia_pgdata:/var/lib/postgresql/data
|
||||||
ports:
|
|
||||||
- "${POSTGRES_PORT:-5432}:5432"
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-amnezia} -d ${POSTGRES_DB:-amnezia_panel}"]
|
test:
|
||||||
|
[
|
||||||
|
"CMD-SHELL",
|
||||||
|
"pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB} && PGPASSWORD=$${POSTGRES_PASSWORD} psql -U $${POSTGRES_USER} -d $${POSTGRES_DB} -c 'SELECT 1' >/dev/null",
|
||||||
|
]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 10
|
retries: 10
|
||||||
@@ -23,7 +26,6 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
image: amnezia-panel:local
|
image: amnezia-panel:local
|
||||||
container_name: amnezia_panel
|
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -33,15 +35,32 @@ services:
|
|||||||
DATABASE_URL: postgresql://${POSTGRES_USER:-amnezia}:${POSTGRES_PASSWORD:-amnezia}@db:5432/${POSTGRES_DB:-amnezia_panel}
|
DATABASE_URL: postgresql://${POSTGRES_USER:-amnezia}:${POSTGRES_PASSWORD:-amnezia}@db:5432/${POSTGRES_DB:-amnezia_panel}
|
||||||
SECRET_KEY: ${SECRET_KEY:-}
|
SECRET_KEY: ${SECRET_KEY:-}
|
||||||
APP_PORT: "5000"
|
APP_PORT: "5000"
|
||||||
|
PORT: "5000"
|
||||||
|
PANEL_IN_DOCKER: "1"
|
||||||
|
PANEL_BEHIND_PROXY: "1"
|
||||||
volumes:
|
volumes:
|
||||||
- amnezia_data:/app/data
|
- amnezia_data:/app/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
- dokploy-network
|
||||||
|
labels:
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.docker.network=dokploy-network
|
||||||
|
expose:
|
||||||
|
- "5000"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:5000/health >/dev/null || exit 1"]
|
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:5000/health >/dev/null || exit 1"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 40s
|
start_period: 60s
|
||||||
|
|
||||||
|
networks:
|
||||||
|
internal:
|
||||||
|
dokploy-network:
|
||||||
|
external: true
|
||||||
|
name: dokploy-network
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
amnezia_data:
|
amnezia_data:
|
||||||
|
|||||||
Reference in New Issue
Block a user