capture/README.md

92 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2019-06-24 20:36:24 +02:00
**Capture** is a reverse proxy that takes an incoming HTTP request and sends it to another server,
2021-02-24 13:35:10 +01:00
proxying the response back to the client, while showing them in a dashboard.
2017-11-08 00:10:54 +01:00
2023-05-29 11:39:33 +02:00
Forked from [ofabricio/capture](https://github.com/ofabricio/capture).
2023-05-26 15:58:51 +02:00
[![status-badge](https://ci.gitnet.fr/api/badges/deblan/capture/status.svg)](https://ci.gitnet.fr/deblan/capture)
2017-11-08 00:10:54 +01:00
2018-07-23 23:49:59 +02:00
## Running
2017-11-08 00:10:54 +01:00
2023-05-26 15:58:51 +02:00
```
./capture -url=https://example.com/ -port 9000 -dashboard 9001 -captures 16
2023-06-06 22:48:38 +02:00
```
Via docker:
```
docker run -p 9000:9000 -p 9001:9001 deblan/capture -url=https://example.com/ -port 9000 -dashboard 9001 -captures 16
2023-05-26 15:58:51 +02:00
```
2017-11-08 00:10:54 +01:00
2019-11-09 12:20:05 +01:00
#### Settings
2017-11-08 00:10:54 +01:00
2023-09-29 15:55:50 +02:00
| param | description |
| -------------- | ------------- |
| `-url` | **Required.** Set the url you want to proxy |
2023-08-03 15:42:22 +02:00
| `-port` | Set the proxy port. Default: *9000* |
| `-dashboard` | Set the dashboard port. Default: *9001* |
| `-captures` | Set how many captures to show in the dashboard. Default: *16* |
| `-tls-skip-verify` | Skip TLS vertificaton. Default: *false* |
| `-config` | Set the configuration file. Default: *.capture.ini* |
2017-11-08 00:10:54 +01:00
You can create a file named `.capture.ini` and set the configuration inside:
```
url = https://example.com/
port = 9000
dashboard = 9001
captures = 16
2023-08-03 15:42:22 +02:00
tls_skip_verify = false
```
2017-11-08 00:10:54 +01:00
## Using
If you set your base url as `http://example.com/api`, now `http://localhost:9000` points to that
address. Hence, calling `http://localhost:9000/users/1` is like calling `http://example.com/api/users/1`
2021-02-24 13:35:10 +01:00
*Capture* saves all requests and responses so that you can see them in the dashboard.
2017-11-08 00:10:54 +01:00
## Dashboard
To access the dashboard go to `http://127.0.0.1:9001/`
2018-07-23 23:49:59 +02:00
2017-11-08 00:10:54 +01:00
##### Preview
2023-05-29 11:06:21 +02:00
![dashboard](https://upload.deblan.org/u/2023-05/64746afd.png)
2018-07-26 01:03:16 +02:00
## Building
Manually:
2023-05-26 15:58:51 +02:00
```
git clone --depth 1 https://gitnet.fr/deblan/capture.git
cd capture
go build
```
2018-07-26 01:03:16 +02:00
Via docker:
2023-05-26 15:58:51 +02:00
```
git clone --depth 1 https://gitnet.fr/deblan/capture.git
cd capture
docker run --rm -v $PWD:/src -w /src -e GOOS=darwin -e GOARCH=amd64 golang:alpine go build
```
2018-11-17 11:55:04 +01:00
2021-02-24 13:35:10 +01:00
Now you have an executable binary in your directory.
2018-11-17 11:55:04 +01:00
2021-02-24 13:35:10 +01:00
**Note:** change `GOOS=darwin` to `linux` or `windows` to create an executable for your corresponding Operating System.
2019-03-10 18:28:14 +01:00
## Plugins
Put [plugin](https://golang.org/pkg/plugin/) files in the current directory.
They are loaded sorted by filename on startup.
Plugins must export the following function:
```go
func Handler(proxy http.HandlerFunc) http.HandlerFunc {
2021-02-24 13:35:10 +01:00
return func(w http.ResponseWriter, r *http.Request) {
proxy(w, r)
2019-03-10 18:28:14 +01:00
}
}
```