golang

proxa, a simple http reverse proxy

Proxa is a simple HTTP reverse proxy I wrote in Golang. It’s useful for the prototyping of web applications, because it is easier and faster to configure than a more fully featured solution like HAProxy - although it’s certainly not ready for production!

It is easy to install:

$ go get github.com/wridgers/proxa

Here is an example configuration:

{
  "frontend": {
    "bind": ":8080",
    "routes": [
      {"prefix": "/api/", "backend": "api"},
      {"prefix": "/", "backend": "default"}
    ]
  },

  "backends": [
    {
      "name":  "default",
      "addrs": ["localhost:8081", "localhost:8082"]
    },
    {
      "name": "api",
      "addrs": ["localhost:8090"]
    }
  ]
}

Proxa is basically a configurable wrapper for httputil.NewSingleHostReverseProxy. It has some neat features like adding an X-Request-ID header that would allow you to trace a request through the network.

Ultimately it’s been a useful tool for me and I am happy with it. When prototyping a project idea I don’t want to break out complex tools like Docker, I can quickly set up Proxa and have requests filtered nicely between a webpack server and a couple of Golang micro services.

References