https://github.com/worldline-go/forward
export connections
https://github.com/worldline-go/forward
docker go traefik
Last synced: over 1 year ago
JSON representation
export connections
- Host: GitHub
- URL: https://github.com/worldline-go/forward
- Owner: worldline-go
- License: mit
- Created: 2022-06-27T19:49:11.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-07T19:20:04.000Z (almost 2 years ago)
- Last Synced: 2024-10-07T21:07:24.519Z (almost 2 years ago)
- Topics: docker, go, traefik
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# forward
[](https://raw.githubusercontent.com/worldline-go/forward/main/LICENSE)
[](https://sonarcloud.io/summary/overall?id=worldline-go_forward)
[](https://github.com/worldline-go/forward/actions)
[](https://pkg.go.dev/github.com/worldline-go/forward)
Export socket connection to HTTP service with filter options.
## Usage
Use `LOG_LEVEL` and `LOG_PRETTY` env values to control the log level and format.
```
Flags:
-h, --help help for forward
-H, --host stringArray Host to listen on (default [0.0.0.0:8080])
-s, --socket stringArray Socket to export: /var/run/docker.sock:/:*,-POST,-PUT,-DELETE
-v, --version version for forward
```
Show the lists of sockets to export with show http methods.
HTTP methods could be any string(case insensitive), and starting with `-` will not allowed.
```sh
# allow all methods to / path
/var/run/docker.sock
# allow all except POST, PUT, DELETE with basepath /docker/
/var/run/docker.sock:/docker/:-POST,-PUT,-DELETE
# Only allow GET requests
/var/run/docker.sock:/docker/:GET
# Disable all methods of requests
/var/run/docker.sock:/docker/:-*
```
```sh
sudo ./forward -s '/var/run/docker.sock:/:-POST,-PUT,-DELETE'
```
If you need multiple ports with multiple sockets than give name before prefix of `@`.
```sh
forward -H localhost@127.0.0.1:8082 -s 'localhost@/var/run/docker.sock'
```
Use `-H` and `-s` more than once to make connections.
```sh
forward -H localhost@127.0.0.1:8082 -s 'localhost@/var/run/docker.sock' -H share@0.0.0.0:8080 -s 'share@/var/run/docker.sock:/:-POST,-PUT,-DELETE'
# 2024-09-07 21:01:45 CEST INF forward version: v0.0.0 commit: - buildDate:-
# 2024-09-07 21:01:45 CEST INF localhost - route [/] to [/var/run/docker.sock]; allow: *; deny:
# 2024-09-07 21:01:45 CEST INF share - route [/] to [/var/run/docker.sock]; allow: *; deny: DELETE,POST,PUT
# 2024-09-07 21:01:45 CEST INF server share on [0.0.0.0:8080]
# 2024-09-07 21:01:45 CEST INF server localhost on [127.0.0.1:8082]
```
If program cannot access the socket, you will get `502 Bad Gateway` on every request.
### Docker
There are scratch and alpine version of container image.
```sh
docker run --rm -it -p 8080:8080 -v /var/run/docker.sock:/docker.sock ghcr.io/worldline-go/forward -s /docker.sock:/:-POST,-PUT,-DELETE,-PATCH
```
## Development
Local generate binary
```sh
make build
```