Feat: Improve Docs (#1791)
* improve docs * preplan guides * fix spelling * fix nftables rules * consistent wg-easy code block * fix grammar
This commit is contained in:
@@ -2,4 +2,37 @@
|
||||
title: API
|
||||
---
|
||||
|
||||
TODO
|
||||
You can use the API to interact with the application programmatically. The API is available at `/api` and supports both GET and POST requests. The API is designed to be simple and easy to use, with a focus on providing a consistent interface for all endpoints.
|
||||
|
||||
There is no documentation for the API yet, but this will be added as the underlying library supports it.
|
||||
|
||||
## Authentication
|
||||
|
||||
To use the API, you need to authenticate using Basic Authentication. The username and password are the same as the ones you use to log in to the web application.
|
||||
If you use 2FA, the API will not work. You need to disable 2FA in the web application to use the API.
|
||||
|
||||
### Authentication Example
|
||||
|
||||
```python
|
||||
import requests
|
||||
from requests.auth import HTTPBasicAuth
|
||||
|
||||
url = "https://example.com:51821/api/client"
|
||||
response = requests.get(url, auth=HTTPBasicAuth('username', 'password'))
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(data)
|
||||
else:
|
||||
print(f"Error: {response.status_code}")
|
||||
```
|
||||
|
||||
## Endpoints
|
||||
|
||||
The Endpoints are not yet documented. But as file-based routing is used, you can find the endpoints in the `src/server/api` folder. The method is defined in the file name.
|
||||
|
||||
### Endpoints Example
|
||||
|
||||
| File Name | Endpoint | Method |
|
||||
| -------------------------------- | -------------- | ------ |
|
||||
| `src/server/api/client.get.ts` | `/api/client` | GET |
|
||||
| `src/server/api/setup/2.post.ts` | `/api/setup/2` | POST |
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: Optional Configuration
|
||||
---
|
||||
|
||||
TODO
|
||||
You can set these environment variables to configure the container. They are not required, but can be useful in some cases.
|
||||
|
||||
| Env | Default | Example | Description |
|
||||
| ---------- | --------- | ----------- | ------------------------------ |
|
||||
|
||||
@@ -26,7 +26,7 @@ If you want to skip the setup process, you have to configure group `1`
|
||||
|
||||
/// note | Security
|
||||
|
||||
The initial username and password is not checked for complexity. Make sure to set a long enough username and a secure password. Otherwise, the user won't be able to log in.
|
||||
The initial username and password is not checked for complexity. Make sure to set a long enough username and password. Otherwise, the user won't be able to log in.
|
||||
|
||||
Its recommended to remove the variables after the setup is done to prevent the password from being exposed.
|
||||
It's recommended to remove the variables after the setup is done to prevent the password from being exposed.
|
||||
///
|
||||
|
||||
@@ -2,6 +2,41 @@
|
||||
title: Prometheus
|
||||
---
|
||||
|
||||
TODO
|
||||
To monitor the WireGuard server, you can use [Prometheus](https://prometheus.io/) and [Grafana](https://grafana.com/). The container exposes a `/metrics/prometheus` endpoint that can be scraped by Prometheus.
|
||||
|
||||
<!-- TOOD: add to docs: Grafana dashboard [21733](https://grafana.com/grafana/dashboards/21733-wireguard/) -->
|
||||
## Enable Prometheus
|
||||
|
||||
To enable Prometheus metrics, go to Admin Panel > General and enable Prometheus.
|
||||
|
||||
You can optionally set a Bearer Password for the metrics endpoints. This is useful if you want to expose the metrics endpoint to the internet.
|
||||
|
||||
## Configure Prometheus
|
||||
|
||||
You need to add a scrape config to your Prometheus configuration file. Here is an example:
|
||||
|
||||
```yaml
|
||||
scrape_configs:
|
||||
- job_name: "wg-easy"
|
||||
scrape_interval: 30s
|
||||
metrics_path: /metrics/prometheus
|
||||
static_configs:
|
||||
- targets:
|
||||
- "localhost:51821"
|
||||
authorization:
|
||||
type: Bearer
|
||||
credentials: "SuperSecurePassword"
|
||||
```
|
||||
|
||||
## Grafana Dashboard
|
||||
|
||||
You can use the following Grafana dashboard to visualize the metrics:
|
||||
|
||||
[](https://grafana.com/grafana/dashboards/21733-wireguard/)
|
||||
|
||||
[21733](https://grafana.com/grafana/dashboards/21733-wireguard/)
|
||||
|
||||
/// note | Unofficial
|
||||
|
||||
The Grafana dashboard is not official and is not maintained by the `wg-easy` team. If you have any issues with the dashboard, please contact the author of the dashboard.
|
||||
See [#1299](https://github.com/wg-easy/wg-easy/pull/1299) for more information.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user