mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 00:26:37 +08:00
[新增] 更新文档
This commit is contained in:
+183
-24
@@ -1,25 +1,54 @@
|
||||
# Deployment
|
||||
|
||||
This page summarizes the OpenFlare deployment baseline, integration flow, upgrade entry points, and Agent install scripts.
|
||||
You will learn the recommended OpenFlare deployment model, Server and Agent requirements, source startup workflow, integration steps, upgrade paths, and uninstall entry points.
|
||||
|
||||
For production, use PostgreSQL for the Server database and set `SESSION_SECRET` explicitly. Agent nodes use Docker OpenResty by default; local OpenResty mode requires `openresty_path` and write paths.
|
||||
|
||||
## Topology
|
||||
|
||||
```text
|
||||
Browser
|
||||
|
|
||||
v
|
||||
OpenFlare Server :3000
|
||||
|
|
||||
| Agent API / heartbeat / config pull
|
||||
v
|
||||
OpenFlare Agent
|
||||
|
|
||||
v
|
||||
Local OpenResty or Docker OpenResty
|
||||
|
|
||||
v
|
||||
Origin service
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
Server:
|
||||
|
||||
* Go 1.25+
|
||||
* Node.js 18+
|
||||
* Writable SQLite directory or reachable PostgreSQL instance
|
||||
| Item | Requirement |
|
||||
| --- | --- |
|
||||
| Go | `1.25+`, source run only |
|
||||
| Node.js | `18+`, frontend source build only |
|
||||
| Database | Writable SQLite directory or reachable PostgreSQL instance |
|
||||
| Port | `3000` by default |
|
||||
|
||||
Agent:
|
||||
|
||||
* Go 1.25+
|
||||
* Writable Agent data directory
|
||||
* Local mode requires `openresty -t` and `openresty -s reload`
|
||||
* Docker mode requires Docker access
|
||||
| Item | Requirement |
|
||||
| --- | --- |
|
||||
| OS | Install script supports Linux and macOS. systemd service is created only on Linux + systemd. |
|
||||
| Architecture | `amd64` or `arm64` |
|
||||
| Docker | Required by the default Docker OpenResty mode |
|
||||
| Local OpenResty | Required only when `openresty_path` is configured |
|
||||
| Network | Agent node must reach the Server URL |
|
||||
|
||||
## Docker Compose
|
||||
[Needs confirmation: recommended production CPU, memory, and disk size]
|
||||
|
||||
PostgreSQL is recommended for production:
|
||||
## Docker Compose Server
|
||||
|
||||
Create `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
@@ -48,8 +77,7 @@ services:
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
SESSION_SECRET: replace-with-random-string
|
||||
SQLITE_PATH: /data/openflare.db
|
||||
SESSION_SECRET: replace-with-a-long-random-string
|
||||
DSN: postgres://openflare:replace-with-strong-password@postgres:5432/openflare?sslmode=disable
|
||||
GIN_MODE: release
|
||||
LOG_LEVEL: info
|
||||
@@ -61,15 +89,48 @@ volumes:
|
||||
openflare-data:
|
||||
```
|
||||
|
||||
Start:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
docker compose ps
|
||||
docker compose logs -f openflare
|
||||
```
|
||||
|
||||
Open `http://localhost:3000`. The default account is `root` / `123456`; change the password immediately.
|
||||
Open `http://localhost:3000`. The default account is `root` / `123456`; change it immediately.
|
||||
|
||||
## Agent Install
|
||||
## Run Server from Source
|
||||
|
||||
Using `discovery_token`:
|
||||
Build the management UI first:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Then start Server:
|
||||
|
||||
```bash
|
||||
cd openflare_server
|
||||
export SESSION_SECRET='replace-with-a-long-random-string'
|
||||
export SQLITE_PATH='./openflare.db'
|
||||
export LOG_LEVEL='info'
|
||||
# Optional: PostgreSQL takes precedence when set.
|
||||
# export DSN='postgres://openflare:secret@127.0.0.1:5432/openflare?sslmode=disable'
|
||||
go run .
|
||||
```
|
||||
|
||||
Default port is `3000`. You can also set it explicitly:
|
||||
|
||||
```bash
|
||||
go run . --port 3000 --log-dir ./logs
|
||||
```
|
||||
|
||||
## Connect Agent
|
||||
|
||||
With `discovery_token`:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
@@ -77,7 +138,7 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/inst
|
||||
--discovery-token YOUR_DISCOVERY_TOKEN
|
||||
```
|
||||
|
||||
Using node-specific `agent_token`:
|
||||
With node-specific `agent_token`:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
@@ -85,18 +146,116 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/inst
|
||||
--agent-token YOUR_AGENT_TOKEN
|
||||
```
|
||||
|
||||
Supported options include `--server-url`, `--discovery-token`, `--agent-token`, `--install-dir`, `--repo`, and `--no-service`.
|
||||
Supported options:
|
||||
|
||||
## Validation
|
||||
| Option | Description |
|
||||
| --- | --- |
|
||||
| `--server-url` | Server URL, required |
|
||||
| `--discovery-token` | First-registration token, mutually exclusive with `--agent-token` |
|
||||
| `--agent-token` | Node-specific token, mutually exclusive with `--discovery-token` |
|
||||
| `--install-dir` | Install directory, default `/opt/openflare-agent` |
|
||||
| `--repo` | GitHub repository for Agent downloads, default `Rain-kl/OpenFlare` |
|
||||
| `--no-service` | Do not create a systemd service |
|
||||
|
||||
1. Prepare `agent_token` or `discovery_token` in the console.
|
||||
2. Start Agent and confirm the node is online.
|
||||
3. Add an enabled reverse proxy site.
|
||||
4. Publish and activate a new version.
|
||||
5. Confirm Agent pulls, validates, reloads, and reports the result.
|
||||
Check status:
|
||||
|
||||
## Uninstall Agent
|
||||
```bash
|
||||
systemctl status openflare-agent
|
||||
journalctl -u openflare-agent -f
|
||||
```
|
||||
|
||||
## Run Agent Manually
|
||||
|
||||
From source:
|
||||
|
||||
```bash
|
||||
cd openflare_agent
|
||||
export LOG_LEVEL='info'
|
||||
go run ./cmd/agent -config /path/to/agent.json
|
||||
```
|
||||
|
||||
Build and run:
|
||||
|
||||
```bash
|
||||
cd openflare_agent
|
||||
go build -o openflare-agent ./cmd/agent
|
||||
export LOG_LEVEL='info'
|
||||
./openflare-agent -config /path/to/agent.json
|
||||
```
|
||||
|
||||
Minimal `agent.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"server_url": "http://127.0.0.1:3000",
|
||||
"agent_token": "replace-with-node-auth-token",
|
||||
"data_dir": "./data",
|
||||
"heartbeat_interval": 10000,
|
||||
"request_timeout": 10000
|
||||
}
|
||||
```
|
||||
|
||||
When `openresty_path` is not configured, Agent uses Docker OpenResty.
|
||||
|
||||
## Minimal Integration Flow
|
||||
|
||||
1. Start Server and sign in.
|
||||
2. Prepare `agent_token` or `discovery_token`.
|
||||
3. Start Agent and confirm the node is online.
|
||||
4. Create an enabled site configuration.
|
||||
5. Publish and activate a new version.
|
||||
6. Check node detail and apply logs.
|
||||
7. Visit the domain or verify with `curl`.
|
||||
|
||||
## Upgrade and Uninstall
|
||||
|
||||
Server:
|
||||
|
||||
* Root users can check and upgrade stable Server releases from the top bar.
|
||||
* Preview releases can be checked manually.
|
||||
* Binary upload upgrades are also supported.
|
||||
|
||||
Agent:
|
||||
|
||||
* Agents follow stable releases by default.
|
||||
* The install script can be rerun to reinstall or upgrade.
|
||||
* Preview upgrades require manual action.
|
||||
|
||||
Uninstall Agent:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/uninstall-agent.sh | bash
|
||||
```
|
||||
|
||||
The uninstall script stops Agent, removes the systemd service and install directory, and attempts to remove the Docker OpenResty container/image when Docker mode is detected. Local `openresty_path` mode does not remove the local OpenResty installation.
|
||||
|
||||
## Validation Commands
|
||||
|
||||
Server:
|
||||
|
||||
```bash
|
||||
cd openflare_server
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
Agent:
|
||||
|
||||
```bash
|
||||
cd openflare_agent
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
Frontend:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Swagger:
|
||||
|
||||
```bash
|
||||
go install github.com/swaggo/swag/cmd/swag@v1.16.4
|
||||
cd openflare_server
|
||||
swag init -g main.go -o docs
|
||||
```
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
# Local Development
|
||||
|
||||
You will learn how to set up a local OpenFlare development environment, run the Server, Agent, and frontend, execute tests and builds, and understand the boundaries contributors must follow.
|
||||
|
||||
This page is for contributors. Product boundaries, data model constraints, API conventions, and frontend layering are defined in [Development Constraints](../design/development.md). This page focuses on executable local workflows.
|
||||
|
||||
## Repository Layout
|
||||
|
||||
| Path | Responsibility |
|
||||
| --- | --- |
|
||||
| `openflare_server` | Gin + GORM + SQLite/PostgreSQL monolithic control plane |
|
||||
| `openflare_server/web` | Next.js management UI, statically exported and served by the Go Server |
|
||||
| `openflare_agent` | Go Agent binary running on nodes |
|
||||
| `scripts` | Agent install and uninstall scripts |
|
||||
| `docs` | VitePress documentation site |
|
||||
|
||||
## Requirements
|
||||
|
||||
| Tool | Requirement |
|
||||
| --- | --- |
|
||||
| Go | `1.25+` |
|
||||
| Node.js | `18+` |
|
||||
| pnpm | Use `corepack enable` to follow the project-declared version |
|
||||
| Docker | Needed for the default Docker OpenResty Agent mode and local integration |
|
||||
| PostgreSQL | Optional. The Server uses SQLite when PostgreSQL is not configured. |
|
||||
|
||||
## Install Frontend Dependencies
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install
|
||||
```
|
||||
|
||||
Build static assets served by the Go Server:
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
## Run the Server
|
||||
|
||||
SQLite:
|
||||
|
||||
```bash
|
||||
cd openflare_server
|
||||
export SESSION_SECRET='dev-session-secret'
|
||||
export SQLITE_PATH='./openflare-dev.db'
|
||||
export LOG_LEVEL='debug'
|
||||
go run .
|
||||
```
|
||||
|
||||
PostgreSQL:
|
||||
|
||||
```bash
|
||||
cd openflare_server
|
||||
export SESSION_SECRET='dev-session-secret'
|
||||
export DSN='postgres://openflare:secret@127.0.0.1:5432/openflare?sslmode=disable'
|
||||
export LOG_LEVEL='debug'
|
||||
go run .
|
||||
```
|
||||
|
||||
Default URL:
|
||||
|
||||
```text
|
||||
http://localhost:3000
|
||||
```
|
||||
|
||||
Default account: `root` / `123456`.
|
||||
|
||||
## Run the Frontend Dev Server
|
||||
|
||||
The frontend dev server listens on `3001` by default and proxies API requests through `NEXT_DEV_BACKEND_URL`:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
export NEXT_DEV_BACKEND_URL='http://127.0.0.1:3000'
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Open:
|
||||
|
||||
```text
|
||||
http://localhost:3001
|
||||
```
|
||||
|
||||
## Run the Agent
|
||||
|
||||
Create a local `agent.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"server_url": "http://127.0.0.1:3000",
|
||||
"agent_token": "replace-with-node-auth-token",
|
||||
"data_dir": "./data",
|
||||
"heartbeat_interval": 10000,
|
||||
"request_timeout": 10000
|
||||
}
|
||||
```
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cd openflare_agent
|
||||
export LOG_LEVEL='debug'
|
||||
go run ./cmd/agent -config ./agent.json
|
||||
```
|
||||
|
||||
When `openresty_path` is not configured, the Agent uses Docker OpenResty. To debug local OpenResty, set `openresty_path`, `main_config_path`, `route_config_path`, `cert_dir`, and `lua_dir`.
|
||||
|
||||
## Tests
|
||||
|
||||
Server:
|
||||
|
||||
```bash
|
||||
cd openflare_server
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
Agent:
|
||||
|
||||
```bash
|
||||
cd openflare_agent
|
||||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||||
```
|
||||
|
||||
Frontend:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
pnpm lint
|
||||
pnpm typecheck
|
||||
pnpm test
|
||||
pnpm test:e2e
|
||||
```
|
||||
|
||||
Docs:
|
||||
|
||||
```bash
|
||||
cd docs
|
||||
pnpm build
|
||||
```
|
||||
|
||||
## Builds
|
||||
|
||||
Frontend static assets:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Server binary:
|
||||
|
||||
```bash
|
||||
cd openflare_server
|
||||
go build -o openflare-server .
|
||||
```
|
||||
|
||||
Agent binary:
|
||||
|
||||
```bash
|
||||
cd openflare_agent
|
||||
go build -o openflare-agent ./cmd/agent
|
||||
```
|
||||
|
||||
## Debugging Entrypoints
|
||||
|
||||
| Scenario | Command or Location |
|
||||
| --- | --- |
|
||||
| Server logs | `LOG_LEVEL=debug go run .` |
|
||||
| Agent logs | `LOG_LEVEL=debug go run ./cmd/agent -config ./agent.json` |
|
||||
| Swagger | `http://localhost:3000/swagger/index.html` |
|
||||
| Frontend API proxy | `NEXT_DEV_BACKEND_URL=http://127.0.0.1:3000 pnpm dev` |
|
||||
| Docker OpenResty container | `docker ps --filter name=openflare-openresty` |
|
||||
|
||||
## Change Acceptance
|
||||
|
||||
Before contributing, confirm that:
|
||||
|
||||
1. The change fits [Product Boundary](../design/index.md).
|
||||
2. The implementation follows [Development Constraints](../design/development.md).
|
||||
3. It does not break release, sync, rollback, or upgrade flows.
|
||||
4. Documentation is updated when configuration, deployment, API, or product boundaries change.
|
||||
5. Risky changes include tests or equivalent integration verification.
|
||||
|
||||
Database schema changes must bump the database version and include explicit migration and validation logic from the previous version.
|
||||
+32
-8
@@ -1,12 +1,36 @@
|
||||
# Guide
|
||||
|
||||
This section helps operators take OpenFlare from first boot to the first working reverse proxy configuration.
|
||||
You will learn how the OpenFlare documentation is organized, which pages to read for a first run, and where to find deployment, usage, troubleshooting, and development information.
|
||||
|
||||
Suggested order:
|
||||
OpenFlare is a self-hosted OpenResty control plane. It brings reverse proxy site configuration, immutable releases, Agent-based node sync, TLS certificates, and basic observability into one management UI for a single team or organization.
|
||||
|
||||
1. [Quick Start](./quick-start.md): run Server with Docker Compose and complete the first login.
|
||||
2. [Deployment](./deployment.md): review production deployment, Agent install, validation, and upgrade.
|
||||
3. [Run Server](./server.md): learn source startup, frontend build, and Swagger access.
|
||||
4. [Connect Agent](./agent.md): use `agent_token` or `discovery_token` to bring a node online.
|
||||
5. [Publish First Site](./first-site.md): create a site configuration, publish it, and verify node application.
|
||||
6. [Upgrade and Maintenance](./upgrade.md): understand upgrade, uninstall, validation, and maintenance entry points.
|
||||
## Recommended Path
|
||||
|
||||
If you are new to OpenFlare, read these pages in order:
|
||||
|
||||
1. [Quick Start](./quick-start.md): start the Server with Docker Compose, sign in, and connect the first Agent.
|
||||
2. [Usage](./usage.md): learn common operations for sites, origins, certificates, releases, rollbacks, and observability.
|
||||
3. [Deployment](./deployment.md): run the Server and Agent in an environment closer to production.
|
||||
4. [Configuration](../reference/configuration.md): look up Server environment variables, runtime options, and Agent configuration fields.
|
||||
5. [Troubleshooting](./troubleshooting.md): debug login, database, node sync, OpenResty apply, and frontend build issues.
|
||||
|
||||
## Find by Role
|
||||
|
||||
| Goal | Start Here |
|
||||
| --- | --- |
|
||||
| Run the management UI in a few minutes | [Quick Start](./quick-start.md) |
|
||||
| Publish the first reverse proxy site | [Publish First Site](./first-site.md) |
|
||||
| Connect or reinstall a node Agent | [Connect Agent](./agent.md) |
|
||||
| Start the Server from source | [Run Server](./server.md) |
|
||||
| Configure GitHub or OIDC login | [SSO Login](./sso.md) |
|
||||
| Upgrade the Server or Agent | [Upgrade and Maintenance](./upgrade.md) |
|
||||
| Contribute code or fix issues | [Local Development](./development.md) and [Development Constraints](../design/development.md) |
|
||||
| Understand architecture and releases | [Architecture](../design/architecture.md) and [Release Model](../design/release-model.md) |
|
||||
|
||||
## Documentation Areas
|
||||
|
||||
`guide/` is for users and operators. It provides executable steps from installation to daily operations.
|
||||
|
||||
`reference/` collects stable facts, such as configuration fields, commands, API conventions, and repository layout.
|
||||
|
||||
`design/` is for maintainers and contributors. It describes product boundaries, architecture, release model, and engineering constraints. Update the related design page before implementing changes that alter those boundaries.
|
||||
|
||||
+121
-14
@@ -1,10 +1,30 @@
|
||||
# Quick Start
|
||||
|
||||
The minimal OpenFlare setup contains one Server and at least one Agent. Server owns the web console, release versions, and node state. Agent runs on proxy nodes and applies OpenResty configuration.
|
||||
You will learn how to start OpenFlare Server with Docker Compose, sign in for the first time, connect the first Agent, and verify that a configuration was published to a node.
|
||||
|
||||
## Run Server
|
||||
The minimal OpenFlare setup contains:
|
||||
|
||||
Docker Compose with PostgreSQL is recommended:
|
||||
| Component | Responsibility |
|
||||
| --- | --- |
|
||||
| Server | Management UI, management API, Agent API, configuration rendering, release publishing, and state storage |
|
||||
| Agent | Runs on proxy nodes, pulls configuration, writes OpenResty files, validates, and reloads |
|
||||
| OpenResty | Receives traffic and proxies requests to origins |
|
||||
|
||||
By default, the Agent uses Docker OpenResty when `openresty_path` is not configured. Prepare Docker on Agent nodes for this quick start.
|
||||
|
||||
## Requirements
|
||||
|
||||
| Item | Requirement |
|
||||
| --- | --- |
|
||||
| Docker / Docker Compose | Used to start Server and PostgreSQL, and used by the default Agent Docker OpenResty mode |
|
||||
| Reachable ports | Server listens on `3000` by default. Agent nodes must reach the Server URL. |
|
||||
| Browser | Used to open the management UI |
|
||||
|
||||
[Needs confirmation: minimum recommended Docker and Docker Compose versions]
|
||||
|
||||
## 1. Start Server
|
||||
|
||||
Create `docker-compose.yml` in an empty directory:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
@@ -32,7 +52,7 @@ services:
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
SESSION_SECRET: replace-with-random-string
|
||||
SESSION_SECRET: replace-with-a-long-random-string
|
||||
DSN: postgres://openflare:replace-with-strong-password@postgres:5432/openflare?sslmode=disable
|
||||
GIN_MODE: release
|
||||
LOG_LEVEL: info
|
||||
@@ -41,13 +61,26 @@ volumes:
|
||||
postgres-data:
|
||||
```
|
||||
|
||||
Start:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Open `http://localhost:3000`.
|
||||
Verify:
|
||||
|
||||
Default credentials:
|
||||
```bash
|
||||
docker compose ps
|
||||
docker compose logs -f openflare
|
||||
```
|
||||
|
||||
When the `openflare` container is running and logs show `server listening`, open:
|
||||
|
||||
```text
|
||||
http://localhost:3000
|
||||
```
|
||||
|
||||
Default account:
|
||||
|
||||
| Username | Password |
|
||||
| --- | --- |
|
||||
@@ -55,9 +88,32 @@ Default credentials:
|
||||
|
||||
Change the default password immediately after first login.
|
||||
|
||||
## Connect a Node
|
||||
## 2. Prepare an Agent Token
|
||||
|
||||
Prepare a `discovery_token` or node-specific `agent_token` in the console, then run the install script on the node.
|
||||
Agents can connect with either:
|
||||
|
||||
| Credential | Use Case |
|
||||
| --- | --- |
|
||||
| `discovery_token` | First-time automatic node registration. Server exchanges it for a node-specific token. |
|
||||
| `agent_token` | A node-specific token created or assigned in the management UI. |
|
||||
|
||||
Prepare one of them in the management UI before continuing.
|
||||
|
||||
[Needs confirmation: exact UI menu path for creating or viewing `discovery_token` and node `agent_token`]
|
||||
|
||||
## 3. Install Agent
|
||||
|
||||
Run the install script on the proxy node.
|
||||
|
||||
With `discovery_token`:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
--server-url http://your-server:3000 \
|
||||
--discovery-token YOUR_DISCOVERY_TOKEN
|
||||
```
|
||||
|
||||
With node-specific `agent_token`:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||||
@@ -65,13 +121,64 @@ curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/inst
|
||||
--agent-token YOUR_AGENT_TOKEN
|
||||
```
|
||||
|
||||
The script installs Agent under `/opt/openflare-agent`, creates `openflare-agent.service`, and uses Docker OpenResty unless a local `openresty_path` is configured.
|
||||
The script defaults to:
|
||||
|
||||
## Publish the First Configuration
|
||||
| Item | Default |
|
||||
| --- | --- |
|
||||
| Install directory | `/opt/openflare-agent` |
|
||||
| Config file | `/opt/openflare-agent/agent.json` |
|
||||
| systemd service | `openflare-agent.service` |
|
||||
| OpenResty mode | Docker OpenResty when `openresty_path` is not configured |
|
||||
|
||||
1. Create a site configuration with a domain and origin URL.
|
||||
2. Preview the release or check the diff before publishing.
|
||||
3. Activate the new version.
|
||||
4. Wait for Agent to discover and apply it through heartbeat.
|
||||
Check status:
|
||||
|
||||
```bash
|
||||
systemctl status openflare-agent
|
||||
journalctl -u openflare-agent -f
|
||||
```
|
||||
|
||||
If systemd is unavailable, the script prints a manual start command.
|
||||
|
||||
## 4. Publish the First Configuration
|
||||
|
||||
In the management UI:
|
||||
|
||||
1. Create a site configuration with a site name, domain, and origin URL.
|
||||
2. Ensure the site is enabled.
|
||||
3. Preview the rendered configuration or review the diff.
|
||||
4. Publish and activate a new version.
|
||||
5. Wait for the Agent to discover and apply the version through heartbeat.
|
||||
|
||||
Version numbers use `YYYYMMDD-NNN`. Historical versions are immutable; rollback reactivates an old version.
|
||||
|
||||
## 5. Verify Success
|
||||
|
||||
In the UI:
|
||||
|
||||
| Location | Expected Result |
|
||||
| --- | --- |
|
||||
| Node list | Agent node is online |
|
||||
| Node detail | Current version matches the active version |
|
||||
| Apply logs | Latest apply succeeded |
|
||||
| Versions page | New version is active |
|
||||
|
||||
On the Agent node:
|
||||
|
||||
```bash
|
||||
journalctl -u openflare-agent -n 100 --no-pager
|
||||
docker ps --filter name=openflare-openresty
|
||||
```
|
||||
|
||||
If Docker OpenResty is used, the default container name is `openflare-openresty`.
|
||||
|
||||
## Common Failures
|
||||
|
||||
| Symptom | What to Check |
|
||||
| --- | --- |
|
||||
| Cannot open the UI | Confirm `docker compose ps` shows Server running and host port `3000` is free |
|
||||
| Login works but data cannot be saved | Check PostgreSQL health and the username/password/database in `DSN` |
|
||||
| Agent cannot register | Confirm the Agent node can reach `--server-url`, and check whether the token is wrong or expired |
|
||||
| Agent is online but does not apply | Confirm the site is enabled and a version was published and activated |
|
||||
| OpenResty apply fails | Check apply logs and `journalctl -u openflare-agent`, especially domains, certificates, upstream URLs, and port conflicts |
|
||||
|
||||
See [Troubleshooting](./troubleshooting.md) for deeper diagnostics.
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
# SSO Login
|
||||
|
||||
You will learn how to configure GitHub OAuth or a standard OIDC login source for OpenFlare, how to set callback URLs, and how third-party accounts bind to local users.
|
||||
|
||||
OpenFlare supports third-party login through authentication sources. The current supported source types are GitHub OAuth and standard OIDC providers, such as Logto, authentik, Keycloak, and Casdoor.
|
||||
|
||||
After an authentication source is configured and enabled, it appears on the login page. Users can sign in with the third-party account or bind it to the current local account while already signed in.
|
||||
|
||||
## Before You Start
|
||||
|
||||
Prepare:
|
||||
|
||||
| Item | Description |
|
||||
| --- | --- |
|
||||
| OpenFlare public URL | The URL users open in their browser, such as `https://openflare.example.com` |
|
||||
| Source name | Internal unique name, such as `github` or `company-oidc` |
|
||||
| Client ID | Provided by the third-party application |
|
||||
| Client Secret | Provided by the third-party application |
|
||||
| OIDC Discovery URL | Required only for OIDC, such as `https://idp.example.com/.well-known/openid-configuration` |
|
||||
|
||||
Confirm that the server address in system settings matches the domain users access.
|
||||
|
||||
The source name can contain letters, numbers, hyphens, and underscores, and must start with a letter or number. The source name is part of the callback URL. If you rename it later, update the callback URL in the third-party platform too.
|
||||
|
||||
## Callback URL
|
||||
|
||||
Set the Redirect URI / Callback URL in the third-party platform to:
|
||||
|
||||
```text
|
||||
<OpenFlare public URL>/oauth/<source name>
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
```text
|
||||
https://openflare.example.com/oauth/github
|
||||
https://openflare.example.com/oauth/company-oidc
|
||||
```
|
||||
|
||||
When creating or editing an authentication source, the UI shows the callback URL based on the current browser URL and source name.
|
||||
|
||||
## Configure GitHub Login
|
||||
|
||||
1. Create an OAuth App in GitHub.
|
||||
2. Set `Homepage URL` to the OpenFlare public URL.
|
||||
3. Set `Authorization callback URL` to the callback shown by OpenFlare, such as `https://openflare.example.com/oauth/github`.
|
||||
4. Copy the Client ID and Client Secret.
|
||||
5. Sign in to OpenFlare and open Settings -> System Settings -> Authentication Sources.
|
||||
6. Add a source and select `GitHub`.
|
||||
7. Fill in source name, display name, Client ID, and Client Secret.
|
||||
8. Keep the default scope `user:email` unless your GitHub app requires a different value.
|
||||
9. Save and enable the source.
|
||||
|
||||
The login page will show the GitHub button after the source is enabled.
|
||||
|
||||
## Configure OIDC Login
|
||||
|
||||
1. Create an application or client in the OIDC provider.
|
||||
2. Choose a Web / Confidential Client type.
|
||||
3. Set Redirect URI / Callback URL to the value shown by OpenFlare, such as `https://openflare.example.com/oauth/company-oidc`.
|
||||
4. Copy the Client ID and Client Secret.
|
||||
5. Get the provider Discovery URL, usually ending in `/.well-known/openid-configuration`.
|
||||
6. Sign in to OpenFlare and open Settings -> System Settings -> Authentication Sources.
|
||||
7. Add a source and select `OIDC`.
|
||||
8. Fill in source name, display name, Client ID, Client Secret, and OIDC Discovery URL.
|
||||
9. Keep the default scope `openid profile email` unless the provider restricts scopes.
|
||||
10. Save and enable the source.
|
||||
|
||||
The login page will show the OIDC button after the source is enabled.
|
||||
|
||||
## Login and Binding Behavior
|
||||
|
||||
| Scenario | Behavior |
|
||||
| --- | --- |
|
||||
| Third-party account already bound to a local user | Sign in directly |
|
||||
| User is already signed in and starts third-party authorization | Bind the third-party account to the current local user |
|
||||
| Third-party account is unbound and registration is allowed | Create a normal local user and bind it |
|
||||
| Third-party account is unbound and registration is disabled | Ask the user to enter existing local credentials to bind |
|
||||
|
||||
If you only want existing users to use SSO, disable registration. Unbound third-party accounts will enter the existing-account binding flow.
|
||||
|
||||
## Update a Source
|
||||
|
||||
When editing an authentication source, leave Client Secret empty to keep the existing secret. Entering a new value overwrites it.
|
||||
|
||||
If you change the source name, the callback URL changes too. Update Redirect URI / Callback URL in the third-party platform, or the provider will reject the callback.
|
||||
|
||||
## FAQ
|
||||
|
||||
### `invalid_scope`
|
||||
|
||||
The provider does not allow the configured scope. The OIDC default is `openid profile email`; the GitHub default is `user:email`. Adjust the scope in OpenFlare or allow it in the provider.
|
||||
|
||||
### Callback URL Mismatch
|
||||
|
||||
Check that the Redirect URI / Callback URL in the provider exactly matches the URL shown by OpenFlare. Protocol, domain, port, and path must all match.
|
||||
|
||||
### No Third-Party Login Button
|
||||
|
||||
Check that the source is enabled and that Client ID and Client Secret are saved. OpenFlare validates these fields before enabling a source.
|
||||
|
||||
### Client Secret Is Not Shown in the List
|
||||
|
||||
This is expected. OpenFlare does not return Client Secret through the API; it only shows whether the secret is configured.
|
||||
@@ -0,0 +1,224 @@
|
||||
# Troubleshooting
|
||||
|
||||
You will learn how to debug OpenFlare Server, database, login, Agent, OpenResty, release, and frontend build issues by symptom.
|
||||
|
||||
Start by locating the failing layer: browser, Server, database, Agent, OpenResty, origin, or DNS. OpenFlare applies configuration only after a version is activated and the Agent discovers it through heartbeat.
|
||||
|
||||
## Quick Triage
|
||||
|
||||
| Symptom | Check First |
|
||||
| --- | --- |
|
||||
| Management UI does not open | Server process/container logs and port binding |
|
||||
| Login fails | Default account, `SESSION_SECRET`, browser request, Server logs |
|
||||
| Data cannot be saved | Database connection, SQLite permissions, PostgreSQL health |
|
||||
| Agent is offline | Agent logs, token, Server URL, network reachability |
|
||||
| Node does not update after release | Active version, node heartbeat, apply logs |
|
||||
| OpenResty apply fails | Apply logs, Agent logs, certificates, upstream URL, port conflicts |
|
||||
| No access analytics | OpenResty status, observability port, Agent replay logs |
|
||||
|
||||
## Server Does Not Start
|
||||
|
||||
1. Check logs:
|
||||
|
||||
```bash
|
||||
docker compose logs -n 200 openflare
|
||||
```
|
||||
|
||||
For source runs, check terminal output.
|
||||
|
||||
2. Check port usage:
|
||||
|
||||
```bash
|
||||
lsof -i :3000
|
||||
```
|
||||
|
||||
3. If PostgreSQL is used, check database health:
|
||||
|
||||
```bash
|
||||
docker compose ps postgres
|
||||
docker compose logs -n 100 postgres
|
||||
```
|
||||
|
||||
4. If SQLite is used, check that the database directory is writable:
|
||||
|
||||
```bash
|
||||
ls -ld "$(dirname /path/to/openflare.db)"
|
||||
```
|
||||
|
||||
Common causes:
|
||||
|
||||
| Log or Symptom | Fix |
|
||||
| --- | --- |
|
||||
| Database connection failed | Check username, password, host, port, database, and `sslmode` in `DSN` |
|
||||
| SQLite cannot create file | Check that the `SQLITE_PATH` directory exists and is writable |
|
||||
| Port is already in use | Change `PORT` or `--port`, or stop the process using the port |
|
||||
|
||||
## UI Does Not Open or Is Blank
|
||||
|
||||
1. Confirm that the Server responds:
|
||||
|
||||
```bash
|
||||
curl -I http://127.0.0.1:3000
|
||||
```
|
||||
|
||||
2. For source runs, confirm frontend static assets were built:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
pnpm build
|
||||
```
|
||||
|
||||
3. Check whether the browser URL matches your reverse proxy setup.
|
||||
|
||||
4. If using the frontend dev server, confirm backend proxy configuration:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
NEXT_DEV_BACKEND_URL=http://127.0.0.1:3000 pnpm dev
|
||||
```
|
||||
|
||||
## Default Account Cannot Sign In
|
||||
|
||||
The default account is `root` / `123456`. If the password was changed after first login, use the updated password.
|
||||
|
||||
Steps:
|
||||
|
||||
1. Confirm the Server is connected to the expected database, not another `SQLITE_PATH` or `DSN`.
|
||||
2. Check Server logs to see whether it uses `sqlite` or `postgres`.
|
||||
3. If deployed behind replicas or a reverse proxy, ensure `SESSION_SECRET` is fixed and consistent across instances.
|
||||
4. Clear browser cookies and try again.
|
||||
|
||||
[Needs confirmation: whether the project provides a safe root password reset command or procedure]
|
||||
|
||||
## Agent Cannot Register or Stays Offline
|
||||
|
||||
On the Agent node:
|
||||
|
||||
```bash
|
||||
curl -I http://your-server:3000
|
||||
```
|
||||
|
||||
Check Agent logs:
|
||||
|
||||
```bash
|
||||
journalctl -u openflare-agent -n 200 --no-pager
|
||||
```
|
||||
|
||||
Check config:
|
||||
|
||||
```bash
|
||||
sed -n '1,160p' /opt/openflare-agent/agent.json
|
||||
```
|
||||
|
||||
Confirm:
|
||||
|
||||
| Config | Notes |
|
||||
| --- | --- |
|
||||
| `server_url` | Must be reachable from the Agent node |
|
||||
| `agent_token` / `discovery_token` | At least one is required |
|
||||
| `heartbeat_interval` | Supports millisecond integers or Go duration strings |
|
||||
| `request_timeout` | Increase it for slow networks |
|
||||
|
||||
If the log says the token is invalid, prepare a new token in the UI, update `agent.json`, and restart:
|
||||
|
||||
```bash
|
||||
systemctl restart openflare-agent
|
||||
```
|
||||
|
||||
## Node Does Not Apply a New Version
|
||||
|
||||
Check in order:
|
||||
|
||||
1. The target version is active on the versions page.
|
||||
2. The node is online and heartbeat time is updating.
|
||||
3. Apply logs contain a success, warning, or failure for the target version.
|
||||
4. The site configuration is enabled.
|
||||
5. Agent logs show pull, validation, reload, or rollback messages.
|
||||
|
||||
Follow Agent logs:
|
||||
|
||||
```bash
|
||||
journalctl -u openflare-agent -f
|
||||
```
|
||||
|
||||
After a target `version + checksum` fails and rolls back, the Agent blocks repeated attempts for that same target locally. Fix the configuration and publish a new checksum, or activate an old version to roll back.
|
||||
|
||||
## OpenResty Apply Fails
|
||||
|
||||
Common causes:
|
||||
|
||||
| Cause | Check |
|
||||
| --- | --- |
|
||||
| Domain or server block conflict | Ensure the same domain is not used by multiple sites |
|
||||
| Invalid upstream URL | Every upstream must be `http://` or `https://` |
|
||||
| Invalid multi-upstream format | Multiple upstreams must be plain `scheme://host[:port]` |
|
||||
| Missing certificate or wrong path | Check domain certificate binding and Agent certificate directory permissions |
|
||||
| Port conflict | Check local or Docker `80` and `443` usage |
|
||||
|
||||
Docker OpenResty mode:
|
||||
|
||||
```bash
|
||||
docker ps --filter name=openflare-openresty
|
||||
docker logs --tail 100 openflare-openresty
|
||||
```
|
||||
|
||||
Local OpenResty mode:
|
||||
|
||||
```bash
|
||||
/usr/local/openresty/nginx/sbin/nginx -t
|
||||
```
|
||||
|
||||
Use the actual path from `openresty_path` in `agent.json`.
|
||||
|
||||
## HTTPS Does Not Work
|
||||
|
||||
1. Confirm the certificate exists.
|
||||
2. Confirm the domain is bound to that certificate in the site configuration.
|
||||
3. Confirm a new version was published and activated.
|
||||
4. Check apply logs for success.
|
||||
5. Inspect with `curl`:
|
||||
|
||||
```bash
|
||||
curl -Iv https://your-domain
|
||||
```
|
||||
|
||||
Domains without a bound certificate are not automatically added to HTTPS configuration.
|
||||
|
||||
## No Access Analytics
|
||||
|
||||
1. Confirm the node applied a configuration that includes observability Lua assets.
|
||||
2. Confirm Docker OpenResty or local OpenResty is running.
|
||||
3. Check Agent logs for collection or replay failures.
|
||||
4. Check whether `openresty_observability_port` is occupied. The default is `18081`.
|
||||
5. Confirm Server cleanup policy did not remove data for that time window.
|
||||
|
||||
## Frontend Build Fails
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
pnpm install
|
||||
pnpm lint
|
||||
pnpm typecheck
|
||||
pnpm test
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Common causes:
|
||||
|
||||
| Symptom | Fix |
|
||||
| --- | --- |
|
||||
| pnpm version mismatch | Run `corepack enable` and reinstall |
|
||||
| Type errors | Run `pnpm typecheck` to locate files |
|
||||
| API type mismatch | Check `lib/api/` and `types/` response structures |
|
||||
| E2E fails | Ensure both the Server and frontend dev server are running |
|
||||
|
||||
## Docs Build Fails
|
||||
|
||||
```bash
|
||||
cd docs
|
||||
pnpm install
|
||||
pnpm build
|
||||
```
|
||||
|
||||
If the failure is a link error, check that new pages are added to `docs/en/config.ts` and that relative links point to existing Markdown files.
|
||||
@@ -0,0 +1,134 @@
|
||||
# Usage
|
||||
|
||||
You will learn what sites, origins, certificates, versions, nodes, and observability mean in OpenFlare, and which order to follow for daily operations.
|
||||
|
||||
OpenFlare does not patch OpenResty configuration files online. You edit control-plane data in the UI; Agents pull and apply a full configuration only after you publish and activate a new version.
|
||||
|
||||
## Core Concepts
|
||||
|
||||
| Concept | Description |
|
||||
| --- | --- |
|
||||
| Site configuration | The reverse proxy aggregation object. One site can bind one or more domains. |
|
||||
| Primary domain | The first item in the `domains` list. |
|
||||
| Origin | The upstream service address, such as `http://10.0.0.10:8080`. |
|
||||
| Configuration version | A full OpenResty configuration snapshot generated by a release. Historical versions are immutable. |
|
||||
| Active version | The globally effective version. By default, all nodes consume the same active version. |
|
||||
| Agent | The node-side process that registers, heartbeats, syncs, validates, reloads, and rolls back on failure. |
|
||||
|
||||
## Recommended Workflow
|
||||
|
||||
For a normal reverse proxy change:
|
||||
|
||||
1. Confirm that at least one Agent node is online.
|
||||
2. Create or select an origin.
|
||||
3. Create a site configuration with domains, upstreams, and site-level settings.
|
||||
4. If HTTPS is needed, upload or select certificates and bind them per domain.
|
||||
5. Preview the rendered configuration or review the diff.
|
||||
6. Publish and activate a new version.
|
||||
7. Check node details and apply logs.
|
||||
|
||||
## Create a Site
|
||||
|
||||
A site requires at least:
|
||||
|
||||
| Field | Requirement |
|
||||
| --- | --- |
|
||||
| Site name | Business-unique identifier. The primary domain is a common default. |
|
||||
| Domains | At least one domain. The first domain is the primary domain. Each domain must be globally unique. |
|
||||
| Origin URL | A valid `http://` or `https://` upstream address. |
|
||||
| Enabled state | Only enabled sites are included in release rendering. |
|
||||
|
||||
Example:
|
||||
|
||||
| Field | Example |
|
||||
| --- | --- |
|
||||
| Site name | `docs` |
|
||||
| Domain | `docs.example.com` |
|
||||
| Origin URL | `http://10.0.0.10:8080` |
|
||||
| Origin Host | `docs.internal.example.com` |
|
||||
|
||||
Upstream rules:
|
||||
|
||||
* A single upstream may include a base path or query string, such as `https://app.example.com/base?from=openflare`.
|
||||
* Multiple upstreams are used for load balancing and must be plain `scheme://host[:port]`.
|
||||
* Multiple upstreams in the same site should use the same protocol.
|
||||
|
||||
## Manage Origins
|
||||
|
||||
Origins are a lightweight reusable address directory. When a site references an origin, the site still stores a renderable `origin_url` snapshot so historical versions can be replayed independently.
|
||||
|
||||
Recommended practices:
|
||||
|
||||
* Store frequently reused internal service addresses as origins.
|
||||
* After changing an origin entry, check whether site snapshots need to be updated.
|
||||
* Use preview or diff before publishing.
|
||||
|
||||
## Enable HTTPS
|
||||
|
||||
HTTPS is bound per domain, not forced for the whole site.
|
||||
|
||||
1. Upload or create a certificate record.
|
||||
2. Open the site configuration and select a certificate for each domain that needs HTTPS.
|
||||
3. Domains without a certificate stay HTTP-only and are not automatically added to `443 ssl` server blocks.
|
||||
4. Publish and activate a new version.
|
||||
|
||||
If a site contains multiple domains, the Server groups HTTPS output by certificate while keeping all domains in the same site snapshot.
|
||||
|
||||
## Release, Activate, and Roll Back
|
||||
|
||||
Standard flow:
|
||||
|
||||
```text
|
||||
Edit configuration -> Preview / diff -> Release -> Generate full version -> Activate version -> Agent pulls -> Agent applies locally -> Agent reports result
|
||||
```
|
||||
|
||||
During release, the Server reads all enabled site configurations, OpenResty main template, performance options, cache options, and certificate assets. It renders a full configuration and calculates a `checksum`.
|
||||
|
||||
Rollback means reactivating an old version. The Agent then applies that version through the normal sync flow.
|
||||
|
||||
## Nodes and Observability
|
||||
|
||||
Node pages answer three questions:
|
||||
|
||||
| Question | Where to Check |
|
||||
| --- | --- |
|
||||
| Is the node online? | Node list or node detail |
|
||||
| Which version is running? | Current version on the node detail page |
|
||||
| Did the last apply succeed? | Apply logs |
|
||||
|
||||
Access analytics and resource snapshots provide basic observability. OpenFlare only keeps access details for a controlled time window; it is not a general-purpose log platform. Use a dedicated logging system for long-term log search.
|
||||
|
||||
## Common Scenarios
|
||||
|
||||
### Add a Reverse Proxy for an Internal Service
|
||||
|
||||
1. Confirm the Agent node can reach the origin service.
|
||||
2. Create a site configuration.
|
||||
3. Add a domain, such as `app.example.com`.
|
||||
4. Add an origin, such as `http://10.0.0.20:8080`.
|
||||
5. Publish and activate the version.
|
||||
6. Verify the domain from a browser or with `curl`.
|
||||
|
||||
### Enable HTTPS for an Existing Domain
|
||||
|
||||
1. Prepare a certificate that covers the domain.
|
||||
2. Upload or create the certificate record.
|
||||
3. Bind the certificate to the domain in the site configuration.
|
||||
4. Publish and activate a new version.
|
||||
5. Verify with `curl -I https://your-domain`.
|
||||
|
||||
### Roll Back a Failed Release
|
||||
|
||||
1. Open the configuration versions page.
|
||||
2. Find the last known good version.
|
||||
3. Activate that version again.
|
||||
4. Check apply logs until the Agent reports success.
|
||||
5. Fix the configuration and publish a new version.
|
||||
|
||||
## Recommended Practices
|
||||
|
||||
* Set `SESSION_SECRET` explicitly in production and prefer PostgreSQL.
|
||||
* Preview or diff changes before release.
|
||||
* Check node details and apply logs after each release.
|
||||
* Keep the network path from Agents to the Server stable.
|
||||
* Do not manually edit OpenFlare-managed OpenResty files on nodes; the next release will overwrite them.
|
||||
Reference in New Issue
Block a user