3x-ui/node/README.md

80 lines
1.9 KiB
Markdown
Raw Normal View History

2026-01-05 21:12:53 +00:00
# 3x-ui Node Service
2026-01-06 00:56:49 +00:00
Node service (worker) for 3x-ui multi-node architecture.
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
## Description
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
This service runs on separate servers and manages XRAY Core instances. The 3x-ui panel (master) sends configurations to nodes via REST API.
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
## Features
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
- REST API for XRAY Core management
- Apply configurations from the panel
- Reload XRAY without stopping the container
- Status and health checks
2026-01-05 21:12:53 +00:00
## API Endpoints
### `GET /health`
2026-01-06 00:56:49 +00:00
Health check endpoint (no authentication required)
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
### `POST /api/v1/apply`
Apply new XRAY configuration
2026-01-05 21:12:53 +00:00
- **Headers**: `Authorization: Bearer <api-key>`
2026-01-06 00:56:49 +00:00
- **Body**: XRAY JSON configuration
2026-01-05 21:12:53 +00:00
### `POST /api/v1/reload`
2026-01-06 00:56:49 +00:00
Reload XRAY
- **Headers**: `Authorization: Bearer <api-key>`
### `POST /api/v1/force-reload`
Force reload XRAY (stops and restarts)
2026-01-05 21:12:53 +00:00
- **Headers**: `Authorization: Bearer <api-key>`
### `GET /api/v1/status`
2026-01-06 00:56:49 +00:00
Get XRAY status
- **Headers**: `Authorization: Bearer <api-key>`
### `GET /api/v1/stats`
Get traffic statistics and online clients
2026-01-05 21:12:53 +00:00
- **Headers**: `Authorization: Bearer <api-key>`
2026-01-06 00:56:49 +00:00
- **Query Parameters**: `reset=true` to reset statistics after reading
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
## Running
2026-01-05 21:12:53 +00:00
### Docker Compose
```bash
cd node
NODE_API_KEY=your-secure-api-key docker-compose up -d --build
```
2026-01-06 00:56:49 +00:00
**Note:** XRAY Core is automatically downloaded during Docker image build for your architecture. Docker BuildKit automatically detects the host architecture. To explicitly specify the architecture, use:
2026-01-05 21:12:53 +00:00
```bash
DOCKER_BUILDKIT=1 docker build --build-arg TARGETARCH=arm64 -t 3x-ui-node -f node/Dockerfile ..
```
2026-01-06 00:56:49 +00:00
### Manual
2026-01-05 21:12:53 +00:00
```bash
go run node/main.go -port 8080 -api-key your-secure-api-key
```
2026-01-06 00:56:49 +00:00
## Environment Variables
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
- `NODE_API_KEY` - API key for authentication (required)
2026-01-05 21:12:53 +00:00
2026-01-06 00:56:49 +00:00
## Structure
2026-01-05 21:12:53 +00:00
```
node/
2026-01-06 00:56:49 +00:00
├── main.go # Entry point
2026-01-05 21:12:53 +00:00
├── api/
2026-01-06 00:56:49 +00:00
│ └── server.go # REST API server
2026-01-05 21:12:53 +00:00
├── xray/
2026-01-06 00:56:49 +00:00
│ └── manager.go # XRAY process management
├── Dockerfile # Docker image
2026-01-05 21:12:53 +00:00
└── docker-compose.yml
```