http-proxy-daemon

module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2022 License: MIT

README

Logo

Http Proxy Daemon

Release version Project language Build Status Release Status Coverage License

This application allows sending any HTTP requests throughout itself (proxying) using dynamic HTTP route, like http://app/proxy/https/example.com/file.json?any=param (request will be sent on https://example.com/file.json?any=param). By running this application on a remote server you can send requests to any resources "like from a server" from anywhere!

Installing

Download the latest binary file for your os/arch from releases page or use our docker image (ghcr.io).

Usage example

Run proxy server:

$ ./http-proxy-daemon serve --port 8080 --prefix 'proxy'

Then send an HTTP request to the https://httpbin.org/get?foo=bar&bar&baz through our server:

$ curl -s -H "foo:bar" --user-agent "fake agent" 'http://127.0.0.1:8080/proxy/https/httpbin.org/get?foo=bar&bar&baz'
{
  "args": {
    "bar": "",
    "baz": "",
    "foo": "bar"
  },
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip",
    "Foo": "bar",
    "Host": "httpbin.org",
    "User-Agent": "fake agent"
  },
  "origin": "8.8.8.8, 1.1.1.1",
  "url": "https://httpbin.org/get?foo=bar&bar&baz"
}

Using docker

image stats

All supported image tags can be found here and here.

Run docker-container with a proxy server in background (detached) and listen for 8080 TCP port (incoming HTTP requests):

$ docker run --rm -d -p "8080:8080/tcp" tarampampam/http-proxy-daemon:X.X.X serve --port 8080

Important notice: do not use latest application tag (this is bad practice). Use versioned tag (like 1.2.3) instead.

Benchmark

Start this application in a docker-container:

$ docker run --rm --net host tarampampam/http-proxy-daemon:0.3.0 serve --port 8080

Start nginx beside:

$ docker run --rm --net host nginx:alpine

Next, run Apache Benchmark:

$ ab -kc 15 -t 90 'http://127.0.0.1:8080/proxy/http/127.0.0.1:80'
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests


Server Software:        nginx/1.19.9
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /proxy/http/127.0.0.1:80
Document Length:        612 bytes

Concurrency Level:      15
Time taken for tests:   7.469 seconds
Complete requests:      50000
Failed requests:        0
Keep-Alive requests:    50000
Total transferred:      44100000 bytes
HTML transferred:       30600000 bytes
Requests per second:    6694.38 [#/sec] (mean)
Time per request:       2.241 [ms] (mean)
Time per request:       0.149 [ms] (mean, across all concurrent requests)
Transfer rate:          5766.06 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     0    2  14.1      1     371
Waiting:        0    2  14.1      1     371
Total:          0    2  14.1      1     371

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      2
  75%      2
  80%      2
  90%      3
  95%      5
  98%      6
  99%      7
 100%    371 (longest request)

Hardware info:

$ cat /proc/cpuinfo | grep 'model name'
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
model name	: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz

$ cat /proc/meminfo | grep 'MemTotal'
MemTotal:       16261464 kB
Testing

For application testing we use built-in golang testing feature and docker-ce + docker-compose as develop environment. So, just write into your terminal after repository cloning:

$ make test

Or build binary file:

$ make build

Changes log

Release date Commits since latest release

Changes log can be found here.

Support

Issues Issues

If you will find any package errors, please, make an issue in current repository.

License

This is open-sourced software licensed under the MIT License.

Directories

Path Synopsis
cmd
http-proxy-daemon
Main CLI application entrypoint.
Main CLI application entrypoint.
internal
pkg/breaker
Package breaker provides OSSignals struct for OS signals handling (with context).
Package breaker provides OSSignals struct for OS signals handling (with context).
pkg/checkers
Package checkers contains different checkers.
Package checkers contains different checkers.
pkg/cli
Package cli contains CLI command handlers.
Package cli contains CLI command handlers.
pkg/cli/healthcheck
Package healthcheck contains CLI `healthcheck` command implementation.
Package healthcheck contains CLI `healthcheck` command implementation.
pkg/cli/serve
Package serve contains CLI `serve` command implementation.
Package serve contains CLI `serve` command implementation.
pkg/cli/version
Package version contains CLI `version` command implementation.
Package version contains CLI `version` command implementation.
pkg/env
Package env contains all about environment variables, that can be used by current application.
Package env contains all about environment variables, that can be used by current application.
pkg/http/handlers/healthz
Package healthz contains healthcheck handler.
Package healthz contains healthcheck handler.
pkg/http/handlers/metrics
Package metrics contains HTTP handler for application metrics (prometheus format) generation.
Package metrics contains HTTP handler for application metrics (prometheus format) generation.
pkg/http/middlewares/logreq
Package logreq contains middleware for HTTP requests logging using "zap" package.
Package logreq contains middleware for HTTP requests logging using "zap" package.
pkg/http/middlewares/panic
Package panic contains middleware for panics (inside HTTP handlers) logging using "zap" package.
Package panic contains middleware for panics (inside HTTP handlers) logging using "zap" package.
pkg/logger
Package logger contains functions for a working with application logging.
Package logger contains functions for a working with application logging.
pkg/metrics
Package metrics contains custom prometheus metrics and registry factories.
Package metrics contains custom prometheus metrics and registry factories.
pkg/version
Package version is used as a place, where application version defined.
Package version is used as a place, where application version defined.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL