mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-10 17:26:38 +08:00
[优化] 更新文档
This commit is contained in:
@@ -1,45 +1,45 @@
|
||||
# Troubleshooting
|
||||
|
||||
You will learn how to debug OpenFlare Server, database, login, Agent, OpenResty, release, and frontend build issues by symptom.
|
||||
You will learn: How to troubleshoot OpenFlare Server, database, login, Agent, OpenResty, configuration publishing, and frontend build issues by symptoms.
|
||||
|
||||
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.
|
||||
During troubleshooting, first identify which layer the issue occurs in: browser, Server, database, Agent, OpenResty, origin server, or DNS. OpenFlare configurations are not written directly to nodes online; only after the active version changes will the Agent detect and apply it in heartbeats.
|
||||
|
||||
## Quick Triage
|
||||
## Quick Diagnostic
|
||||
|
||||
| Symptom | Check First |
|
||||
| Symptom | Where to 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 |
|
||||
| Admin panel fails to open | Server container or process logs, port listening |
|
||||
| Login anomalies | Default credentials, Session Secret, browser request payloads, Server logs |
|
||||
| Data fails to save | Database connection, SQLite file permissions, PostgreSQL health |
|
||||
| Agent offline | Agent logs, Token, Server URL, network connectivity |
|
||||
| Node not updated after publishing | Active version, node heartbeat, application logs |
|
||||
| OpenResty application failed | Application logs, Agent logs, certificates, upstream addresses, port conflicts |
|
||||
| Observability analytics has no data | OpenResty container status, observability port, Agent retry logs |
|
||||
|
||||
## Server Does Not Start
|
||||
## Server Fails to Start
|
||||
|
||||
1. Check logs:
|
||||
1. View logs:
|
||||
|
||||
```bash
|
||||
docker compose logs -n 200 openflare
|
||||
```
|
||||
|
||||
For source runs, check terminal output.
|
||||
For source-code execution, inspect terminal outputs.
|
||||
|
||||
2. Check port usage:
|
||||
2. Check port conflicts:
|
||||
|
||||
```bash
|
||||
lsof -i :3000
|
||||
```
|
||||
|
||||
3. If PostgreSQL is used, check database health:
|
||||
3. If using PostgreSQL, verify that the database is healthy:
|
||||
|
||||
```bash
|
||||
docker compose ps postgres
|
||||
docker compose logs -n 100 postgres
|
||||
```
|
||||
|
||||
4. If SQLite is used, check that the database directory is writable:
|
||||
4. If using SQLite, verify that the database directory is writable:
|
||||
|
||||
```bash
|
||||
ls -ld "$(dirname /path/to/openflare.db)"
|
||||
@@ -47,154 +47,178 @@ ls -ld "$(dirname /path/to/openflare.db)"
|
||||
|
||||
Common causes:
|
||||
|
||||
| Log or Symptom | Fix |
|
||||
| Log or Symptom | Action |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
| Database connection failed | Check `DSN` username, password, host, port, dbname, and `sslmode` |
|
||||
| SQLite fails to create files | Check if the parent directory of `SQLITE_PATH` exists and is writable |
|
||||
| Port is already in use | Change `PORT` or `--port`, or stop the process binding to the port |
|
||||
|
||||
## UI Does Not Open or Is Blank
|
||||
## Admin Console Fails to Load or Shows Blank Page
|
||||
|
||||
1. Confirm that the Server responds:
|
||||
1. Verify that the Server is listening:
|
||||
|
||||
```bash
|
||||
curl -I http://127.0.0.1:3000
|
||||
```
|
||||
|
||||
2. For source runs, confirm frontend static assets were built:
|
||||
2. If running from source, verify that the frontend static assets have been built:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
pnpm build
|
||||
```
|
||||
|
||||
3. Check whether the browser URL matches your reverse proxy setup.
|
||||
3. Verify if the browser URL matches your reverse proxy domain.
|
||||
|
||||
4. If using the frontend dev server, confirm backend proxy configuration:
|
||||
4. If accessing via the frontend dev server, verify the 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
|
||||
## Default Credentials Fail to Log In
|
||||
|
||||
The default account is `root` / `123456`. If the password was changed after first login, use the updated password.
|
||||
The default credentials are `root` / `123456`. If you have modified the password after your first login, use your new password.
|
||||
|
||||
Steps:
|
||||
Troubleshooting 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.
|
||||
1. Confirm that you are connecting to the expected database, avoiding `SQLITE_PATH` or `DSN` pointing to a different environment.
|
||||
2. Check the Server log to see if it is running on `sqlite` or `postgres`.
|
||||
3. If deployed in multi-replicas or behind a reverse proxy, verify that `SESSION_SECRET` is static and uniform across all instances.
|
||||
4. Clear browser Cookies and try logging in again.
|
||||
|
||||
[Needs confirmation: whether the project provides a safe root password reset command or procedure]
|
||||
### Emergency Reset of Admin Password
|
||||
|
||||
## Agent Cannot Register or Stays Offline
|
||||
If you forget the password for the `root` account, you can reset it back to `123456` by directly updating the password hash in the database (please change it immediately after logging in):
|
||||
|
||||
On the Agent node:
|
||||
#### 1. If using SQLite Database
|
||||
Stop the Server and open the database file using the `sqlite3` client:
|
||||
```bash
|
||||
sqlite3 /path/to/openflare.db
|
||||
```
|
||||
Execute the following SQL statement:
|
||||
```sql
|
||||
UPDATE users SET password_hash = '$2a$10$wN9aE3zTz83rO7R1uKlhuehJtA3c604pX4Z12B/9.5c0X337t1L4m' WHERE username = 'root';
|
||||
```
|
||||
Type `.exit` to exit and restart the Server.
|
||||
|
||||
#### 2. If using PostgreSQL Database
|
||||
Connect to your PostgreSQL instance using a database tool (e.g., `psql`, `pgAdmin`, or `DBeaver`), select the corresponding `openflare` database, and execute the following SQL:
|
||||
```sql
|
||||
UPDATE users SET password_hash = '$2a$10$wN9aE3zTz83rO7R1uKlhuehJtA3c604pX4Z12B/9.5c0X337t1L4m' WHERE username = 'root';
|
||||
```
|
||||
Once executed successfully, you can log in using the default password `123456`.
|
||||
|
||||
## Agent Fails to Register or Stays Offline
|
||||
|
||||
Execute on the Agent node:
|
||||
|
||||
```bash
|
||||
curl -I http://your-server:3000
|
||||
```
|
||||
|
||||
Check Agent logs:
|
||||
Inspect Agent logs:
|
||||
|
||||
```bash
|
||||
journalctl -u openflare-agent -n 200 --no-pager
|
||||
```
|
||||
|
||||
Check config:
|
||||
Verify configuration parameters:
|
||||
|
||||
```bash
|
||||
sed -n '1,160p' /opt/openflare-agent/agent.json
|
||||
```
|
||||
|
||||
Confirm:
|
||||
Key Settings:
|
||||
|
||||
| Config | Notes |
|
||||
| Configuration | Description |
|
||||
| --- | --- |
|
||||
| `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 |
|
||||
| `server_url` | Must be the Server address reachable by the Agent node |
|
||||
| `agent_token` / `discovery_token` | At least one must be provided |
|
||||
| `heartbeat_interval` | Supports integer milliseconds or Go duration strings |
|
||||
| `request_timeout` | Can be increased for slower network links |
|
||||
|
||||
If the log says the token is invalid, prepare a new token in the UI, update `agent.json`, and restart:
|
||||
If the log warns that the Token is invalid, retrieve a new Token in the management console, update `agent.json`, and restart the Agent:
|
||||
|
||||
```bash
|
||||
systemctl restart openflare-agent
|
||||
```
|
||||
|
||||
## Node Does Not Apply a New Version
|
||||
## Node Fails to Apply New Version after Publishing
|
||||
|
||||
Check in order:
|
||||
Verify in sequence:
|
||||
|
||||
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.
|
||||
1. Confirm that the target version is activated on the Versions page.
|
||||
2. Verify if the node is online and if its last heartbeat time has updated.
|
||||
3. Check the Application Logs for successful, warned, or failed logs for the target version.
|
||||
4. Verify if the website configuration is enabled; disabled websites do not participate in rendering.
|
||||
5. Inspect Agent logs for pulls, validations, reloads, or rollback events.
|
||||
|
||||
Follow Agent logs:
|
||||
Inspect 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.
|
||||
Note: If a target `version + checksum` fails to apply and triggers a rollback, the Agent blocks repeated synchronization of that failing target in its local state. You must fix the configuration issues and republish to generate a new checksum, or activate an older version to trigger a rollback.
|
||||
|
||||
## OpenResty Apply Fails
|
||||
If this is the Agent's first time applying configurations and no historic `nginx.conf` exists locally to roll back to, the failed version remains blocked but the Agent will attempt to enter the safe fallback runtime. At this point, the application logs and Agent logs will contain `fallback runtime started`. OpenResty will only listen to port `80`, returning a `503` with the body `OpenFlare: No Valid Configuration`, while retaining the local `/openflare/stub_status` health probe. After correcting the configurations and republishing, the Agent overrides the fallback config and restores normal reverse proxies.
|
||||
|
||||
Common causes:
|
||||
## OpenResty Application Fails
|
||||
|
||||
| Cause | Check |
|
||||
Common Causes:
|
||||
|
||||
| Cause | Diagnostic |
|
||||
| --- | --- |
|
||||
| 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 `80` and `443` usage |
|
||||
| Domain or server block conflict | Verify if the same domain is used by multiple website configurations |
|
||||
| Invalid upstream address | Confirm that all upstreams are valid `http://` or `https://` URLs |
|
||||
| Mismatched multi-upstream format | Multi-upstreams must be pure `scheme://host[:port]` |
|
||||
| Missing cert or invalid paths | Verify if domains are bound to certs and check if the Agent cert directory is writable |
|
||||
| Port already in use | Verify ports `80` and `443` on the host |
|
||||
|
||||
OpenResty config test:
|
||||
OpenResty Configuration Validation:
|
||||
|
||||
```bash
|
||||
openresty -t -c /path/to/openflare/data/etc/nginx/nginx.conf
|
||||
```
|
||||
|
||||
OpenResty runtime:
|
||||
OpenResty Runtime Status:
|
||||
|
||||
```bash
|
||||
ps aux | grep openresty
|
||||
```
|
||||
|
||||
Agent periodic health checks use local `http://127.0.0.1:<openresty_observability_port>/openflare/stub_status` instead of repeatedly running `openresty -t`. If a node is unhealthy, first confirm that the local observability port is listening. If `host not found in upstream` only appears during apply, the failure comes from config validation or reload, not the periodic health probe.
|
||||
The Agent determines OpenResty survival periodically using the local endpoint `http://127.0.0.1:<openresty_observability_port>/openflare/stub_status`, completely bypassing repeated `openresty -t` calls. If a node is marked as unhealthy, confirm if this local observability port is listening. If failures only occur when applying configurations (e.g., `host not found in upstream`), the failure lies in config validation or reload, not the periodic health checks.
|
||||
|
||||
Use the actual `openresty_path` and `main_config_path` from `agent.json`.
|
||||
Actual binary paths and main configuration paths are governed by `openresty_path` and `main_config_path` in `agent.json`.
|
||||
|
||||
## HTTPS Does Not Work
|
||||
## HTTPS Fails to 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`:
|
||||
1. Verify that the certificate has been uploaded or hosted.
|
||||
2. Verify that the website configuration binds the certificate to the domain.
|
||||
3. Confirm that the configuration version has been published and activated.
|
||||
4. Check if the Application Logs indicate a success.
|
||||
5. Check the certificate chain and status code using `curl`:
|
||||
|
||||
```bash
|
||||
curl -Iv https://your-domain
|
||||
```
|
||||
|
||||
Domains without a bound certificate are not automatically added to HTTPS configuration.
|
||||
Domains without a bound certificate will not be added to the HTTPS configuration automatically; this is expected behavior.
|
||||
|
||||
## No Access Analytics
|
||||
## Traffic Analytics Has No Data
|
||||
|
||||
1. Confirm the node applied a configuration that includes observability Lua assets.
|
||||
2. Confirm 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.
|
||||
1. Confirm that the node has successfully applied configurations carrying observability Lua scripts.
|
||||
2. Verify that OpenResty is running.
|
||||
3. Check Agent logs for observability extraction or upload errors.
|
||||
4. Check if `openresty_observability_port` (default is `18081`) is bound by other processes.
|
||||
5. Verify if the Server database has purged data inside the time window.
|
||||
|
||||
## Frontend Build Fails
|
||||
|
||||
Execute:
|
||||
|
||||
```bash
|
||||
cd openflare_server/web
|
||||
corepack enable
|
||||
@@ -207,14 +231,14 @@ pnpm build
|
||||
|
||||
Common causes:
|
||||
|
||||
| Symptom | Fix |
|
||||
| Symptom | Action |
|
||||
| --- | --- |
|
||||
| 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 |
|
||||
| pnpm version mismatch | Reinstall packages after executing `corepack enable` |
|
||||
| TypeScript errors | Locate detailed file bugs by running `pnpm typecheck` |
|
||||
| API type mismatch | Check responses structures in `lib/api/` and `types/` |
|
||||
| E2E test failures | Confirm that both the Server and frontend dev server are running |
|
||||
|
||||
## Docs Build Fails
|
||||
## Documentation Build Fails
|
||||
|
||||
```bash
|
||||
cd docs
|
||||
@@ -222,4 +246,4 @@ 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.
|
||||
If it fails on broken links, check if new pages are added to the `docs/config.ts` sidebar, or if relative markdown links point to existing markdown files.
|
||||
|
||||
Reference in New Issue
Block a user