Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schnoddelbotz/uds-proxy
uds-proxy provides a UNIX domain socket that acts as HTTP(S) connection-pooling forward proxy
https://github.com/schnoddelbotz/uds-proxy
connection-pooling domain-socket go http https prometheus-metrics proxy unix
Last synced: 2 months ago
JSON representation
uds-proxy provides a UNIX domain socket that acts as HTTP(S) connection-pooling forward proxy
- Host: GitHub
- URL: https://github.com/schnoddelbotz/uds-proxy
- Owner: schnoddelbotz
- License: mit
- Created: 2019-05-26T16:34:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T00:17:28.000Z (over 5 years ago)
- Last Synced: 2024-08-03T23:29:21.335Z (4 months ago)
- Topics: connection-pooling, domain-socket, go, http, https, prometheus-metrics, proxy, unix
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - uds-proxy - proxy provides a UNIX domain socket that acts as HTTP(S) connection-pooling forward proxy (Repositories)
README
# uds-proxy [![goreportcard](https://goreportcard.com/badge/github.com/schnoddelbotz/uds-proxy)](https://goreportcard.com/report/github.com/schnoddelbotz/uds-proxy) [![GoDoc](https://godoc.org/github.com/PuerkitoBio/rehttp?status.png)](https://godoc.org/github.com/schnoddelbotz/uds-proxy/proxy)
uds-proxy provides a UNIX domain socket and forwards traffic to HTTP(S) remotes
through a customizable connection pool (i.e. using persistent connections).## what for? why? how?
Interacting with microservices often involves communication overhead: Every contact
with another service may involve DNS lookups and establishment of a TCP connection
plus, most likely, a HTTPS handshake.This overhead can be costly and especially hard to circumvent for legacy applications -- thus uds-proxy.
uds-proxy creates a UNIX domain socket and forwards communication to one or more
remote web servers. In a way, uds-proxy aims a bit at reducing application/API complexity by
providing a generic and simple solution for connection pooling.uds-proxy is implemented in Go, so it runs as native application on any
OS supporting Go and UNIX domain sockets (i.e. not on Windows). Critical
performance metrics of uds-proxy (request latencies, response codes...)
and Go process statistics are exposed through Prometheus client library.## building / installing uds-proxy
Building requires a local Go 1.11+ installation:
```bash
go get -v github.com/schnoddelbotz/uds-proxy/cmd/uds-proxy
```... or just grab a [uds-proxy binary release](https://github.com/schnoddelbotz/uds-proxy/releases).
See [usage-example-for-an-https-endpoint](#usage-example-for-an-https-endpoint) for Docker usage.
To start uds-proxy at system boot, create e.g. a systemd unit.
Don't try to run uds-proxy as root. It won't start.## usage
```
Usage of ./uds-proxy:
-client-timeout int
http client connection timeout [ms] for proxy requests (default 5000)
-idle-timeout int
connection timeout [ms] for idle backend connections (default 90000)
-max-conns-per-host int
maximum number of connections per backend host (default 20)
-max-idle-conns int
maximum number of idle HTTP(S) connections (default 100)
-max-idle-conns-per-host int
maximum number of idle conns per backend (default 25)
-no-access-log
disable proxy access logging
-no-log-timestamps
disable timestamps in log messages
-pid-file string
pid file to use, none if empty
-prometheus-port string
Prometheus monitoring port, e.g. :18080
-remote-https
remote uses https://
-socket string
path of socket to create
-socket-read-timeout int
read timeout [ms] for -socket (default 5000)
-socket-write-timeout int
write timeout [ms] for -socket (default 5000)
-version
print uds-proxy version
```## monitoring / testing / development
Clone this repository and check the [Makefile](Makefile) targets.
Most relevant `make` targets:
- `make monitoring_test` spins up Prometheus, grafana and uds-proxy using Docker and
starts another uds-proxy instance locally (outside Docker, on Mac only). The uds-proxy instances will be
scraped by dockerized Prometheus and Grafana will provide dashboards.
See [monitoring/README.md](monitoring/README.md) for details.
- `make run_proxy` starts a local uds-proxy instance for testing purposes.
`TEST_SOCKET` environment variable controls socket location, defaults
to `uds-proxy-test.socket`.
- `make test` runs unit and functional tests from [proxy_test](proxy_test) directory.
- `make coverage` generates code test coverage statistics.
- `make test_integration` starts a local uds-proxy and runs some proxied-vs-non-proxied perf tests.
- `make realclean` removes leftovers from tests or builds.### usage example for an HTTPS endpoint
Start the proxy:```bash
uds-proxy -socket /tmp/proxied-svc.sock -prometheus-port :28080 -remote-https
```Docker users:
```bash
mkdir -p /tmp/mysock_dir
docker run --rm -it -p28080:28080 -v/tmp/mysock_dir:/tmp schnoddelbotz/uds-proxy
```For both cases, metrics should be available at http://localhost:28080/metrics while uds-proxy is running.
#### using bash / curl
```bash
# without uds-proxy, you would...
time curl -I https://www.google.com/# with uds-proxy, always ...
# a) talk through socket and
# b) use http:// and let `-remote-https` ensure https is used to connect to remote hosts
time curl -I --unix-socket /tmp/proxied-svc.sock http://www.google.com/
# ... or using socket provided by dockerized uds-proxy:
time curl -I --unix-socket /tmp/mysock_dir/uds-proxy-docker.sock http://www.google.com/
```#### using php / curl
```php