All Projects → Integralist → go-reverse-proxy

Integralist / go-reverse-proxy

Licence: MIT license
Reverse proxy with simple routing configuration and override behaviour

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to go-reverse-proxy

Ergo
The management of multiple apps running over different ports made easy
Stars: ✭ 452 (+2052.38%)
Mutual labels:  proxy-server, reverse-proxy
Mongols
C++ high performance networking with TCP/UDP/RESP/HTTP/WebSocket protocols
Stars: ✭ 250 (+1090.48%)
Mutual labels:  proxy-server, reverse-proxy
throo
A Vert.x/Spring based HTTP reverse-proxy
Stars: ✭ 19 (-9.52%)
Mutual labels:  proxy-server, reverse-proxy
mps
MPS is a high-performance HTTP(S) proxy library that supports forward proxies, reverse proxies, man-in-the-middle proxies, tunnel proxies, Websocket proxies. MPS 是一个高性能HTTP(s)中间代理库,它支持正向代理、反向代理、中间人代理、隧道代理、Websocket代理
Stars: ✭ 64 (+204.76%)
Mutual labels:  proxy-server, reverse-proxy
http-knocking
🚪HTTP-Knocking hides a Web server and open it by knocking sequence: Hide Web server until your knocks
Stars: ✭ 28 (+33.33%)
Mutual labels:  proxy-server, reverse-proxy
node-proxy
High performance HTTP and reverse proxy server based on Node.js. 基于 Node.js 的高性能 HTTP 及反向代理服务器,类似nginx。
Stars: ✭ 71 (+238.1%)
Mutual labels:  proxy-server, reverse-proxy
Noginx
High performance HTTP and reverse proxy server based on Node.js. 基于 Node.js 的高性能 HTTP 及反向代理服务器,类似nginx。
Stars: ✭ 53 (+152.38%)
Mutual labels:  proxy-server, reverse-proxy
json-caching-proxy
Node caching HTTP proxy built on top of express-http-proxy. Persists requests and responses to an in-memory HAR-like data structure based on HAR1.2 . Caches JSON content-type responses by default with the ability to cache an entire site; including content-types describing images. Useful for testing front end code, mocking api, and saving the cac…
Stars: ✭ 31 (+47.62%)
Mutual labels:  proxy-server, reverse-proxy
tunman
Comprehensive solution for SSH tunnels - respawning, healthchecking/monitoring
Stars: ✭ 43 (+104.76%)
Mutual labels:  routing, reverse-proxy
p3y
A single binary reverse proxy written in go. It was developed for use in Kubernetes, to wrap services like Prometheus with simple BasicAuth and TLS encryption.
Stars: ✭ 15 (-28.57%)
Mutual labels:  proxy-server, reverse-proxy
bproxy
high-performance minimal HTTP reverse proxy
Stars: ✭ 28 (+33.33%)
Mutual labels:  proxy-server, reverse-proxy
reproxy
Simple edge server / reverse proxy
Stars: ✭ 994 (+4633.33%)
Mutual labels:  proxy-server, reverse-proxy
flow-router
🚦 Carefully extended flow-router for Meteor
Stars: ✭ 191 (+809.52%)
Mutual labels:  routing
routing-py
🌎 Python library to access all public routing, isochrones and matrix APIs in a consistent manner.
Stars: ✭ 106 (+404.76%)
Mutual labels:  routing
RouteNow
RouteNow is a small fast library ⚡ that will help you in developing a SinglePage Application without any dependencies like jQuery, AngularJs, vue.js or any of those bulky frameworks.
Stars: ✭ 17 (-19.05%)
Mutual labels:  routing
gweatherrouting
Sailing weather routing made easy
Stars: ✭ 15 (-28.57%)
Mutual labels:  routing
STCRouter
基于标准URL的iOS路由系统,可实现业务模块组件化,控制器之间零耦合,可实现黑白名单控制,可进行native降级到hybrid。
Stars: ✭ 19 (-9.52%)
Mutual labels:  routing
composer-velocita
Velocita - Composer plugin for transparent caching
Stars: ✭ 26 (+23.81%)
Mutual labels:  reverse-proxy
neteng-roadmap
Network Engineering at Scale Roadmap/Landscape
Stars: ✭ 53 (+152.38%)
Mutual labels:  routing
stackdriver-reverse-proxy
Simple HTTP proxy to automatically traces the incoming requests
Stars: ✭ 41 (+95.24%)
Mutual labels:  reverse-proxy

Go Reverse Proxy

A simple configuration-driven reverse proxy written in Go.

It has zero dependencies outside of the Go standard library.

Configuration

Define a slice of type Config, with the minimum set of fields being: Path and Upstream.

Configuration is defined in the routing/configuration file.

Upstreams are defined in the upstreams file.

Example Config

Below we explain the actual routing configuration committed into this repo...

Proxy Request

Config{
  Path:     "/anything/standard",
  Upstream: upstreams.HTTPBin,
}

Requests

  • /anything/standard

Result

The request will be proxied straight through to the specified upstream without any modifications.


Proxy Request using Regular Expression

Config{
  Path:     "/anything/(?:foo|bar)$",
  Upstream: upstreams.HTTPBin,
}

Requests

  • /anything/foo
  • /anything/bar

Result

Both requests will be proxied straight through to the specified upstream without any modifications.


Proxy Request with Modified Path

Config{
  Path:       `/(?P<cap>foo\w{3})`,
  Upstream:   upstreams.HTTPBin,
  ModifyPath: "/anything/${cap}",
}

Requests

  • /fooabc
  • /fooxyz

Result

Both requests will be proxied through to the specified upstream but the path will be modified to include the captured information: /anything/abc and /anything/xyz.


Override with Modified Path

Config{
  Path:     "/(?P<start>anything)/(?P<cap>foobar)$",
  Upstream: upstreams.HTTPBin,
  Override: Override{
    Header:     "X-BF-Testing",
    Match:      "integralist",
    ModifyPath: "/anything/newthing${cap}",
  },
}

Requests

  • /anything/foobar
  • /anything/foobar (+ HTTP Request Header X-BF-Testing: integralist)

Result

The request will be proxied straight through to the specified upstream without any modifications.

If the relevant request header is specified, then the request will be proxied through to the specified upstream but the path will be modified to include the captured information: /anything/newthingfoobar.


Modified Path + Override with Modified Path

Config{
  Path:       "/(?P<cap>double-checks)$",
  Upstream:   upstreams.HTTPBin,
  ModifyPath: "/anything/toplevel-modified-${cap}",
  Override: Override{
    Header:     "X-BF-Testing",
    Match:      "integralist",
    ModifyPath: "/anything/override-modified-${cap}",
  },
}

Requests

  • /double-checks
  • /double-checks (+ HTTP Request Header X-BF-Testing: integralist)

Result

The request will be proxied through to the specified upstream but the path will be modified to include the captured information: /anything/toplevel-modified-double-checks.

If the relevant request header is specified, then the request will be proxied through to the specified upstream but the path will be modified to include the captured information: /anything/override-modified-double-checks.


Override to Different Upstream

Config{
  Path:     "/anything/(?P<cap>integralist)",
  Upstream: upstreams.HTTPBin,
  Override: Override{
    Header:     "X-BF-Testing",
    Match:      "integralist",
    ModifyPath: "/about",
    Upstream:   upstreams.Integralist,
  },
}

Requests

  • /anything/integralist
  • /anything/integralist (+ HTTP Request Header X-BF-Testing: integralist)

Result

The request will be proxied straight through to the specified upstream without any modifications.

If the relevant request header is specified, then the request will be proxied through to a different specified upstream and the path will also be modified.

Note: although we use a named capture group, we don't actually utilise it anywhere in the rest of the configuration, so it's effectively a no-op.


Query String Override

Config{
  Path:     "/about",
  Upstream: upstreams.HTTPBin,
  Override: Override{
    Query:    "s",
    Match:    "integralist",
    Upstream: upstreams.Integralist,
  },
}

Requests

  • /about
  • /about?s=integralist

Result

The request will be proxied straight through to the specified upstream without any modifications.

If the relevant query parameter is specified, then the request will be proxied through to a different specified upstream.


Query String Override with Regular Expression

Config{
  Path:     "/anything/querytest",
  Upstream: upstreams.HTTPBin,
  Override: Override{
    Query:      "s",
    Match:      `integralist(?P<cap>\d{1,3})$`,
    MatchType:  "regex",
    ModifyPath: "/anything/newthing${cap}",
  },
}

Requests

  • /anything/querytest
  • /anything/querytest?s=integralist123
  • /anything/querytest?s=integralist456

Result

The first request will be proxied straight through to the specified upstream without any modifications.

If the relevant query parameter is specified, then the second and third requests will have their path modified to include the captured information: /anything/newthing123 and /anything/newthing456.

Response Headers

We set the following response headers (not all will be set depending on the configuration):

X-Forwarded-Host
X-Origin-Host
X-Router-Upstream
X-Router-Upstream-OriginalHost
X-Router-Upstream-OriginalPath
X-Router-Upstream-OriginalPathModified
X-Router-Upstream-Override
X-Router-Upstream-OverrideHost
X-Router-Upstream-OverridePath

Usage

make run

Note: the application listens on port 9001.

curl -v http://localhost:9001/some/path/you/configured

Tests

make test

Load Test

We use vegeta for load testing, so make sure you have that installed.

make stress

Example output:

Requests      [total, rate]            1500, 50.03
Duration      [total, attack, wait]    30.11237994s, 29.982166788s, 130.213152ms
Latencies     [mean, 50, 95, 99, max]  154.522948ms, 96.76258ms, 358.770472ms, 1.076826656s, 2.954136535s
Bytes In      [total, mean]            2039772, 1359.85
Bytes Out     [total, mean]            0, 0.00
Success       [ratio]                  100.00%
Status Codes  [code:count]             200:1500
Error Set:

TODO

  • Look at implementing thread pool processing on a host or server basis.
  • Verify if DNS caching (or request memoization) would affect latency results?
  • Review 301 redirect behaviour to be sure we don't need to handle that differently.
  • Flesh out some unit tests (not just integration testing)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].