Environment-configurable HTTP reverse proxy for HTTP and NSQ upstreams
1.1K
This is a simplistic reverse proxy for HTTP and NSQ upstreams.
It gathers its configuration from the environment to map a resouce with an upstream. Every HTTP verb has to be configured independently.
The initialisation function will parse all the environment variable keys starting with the prefix PROXY_. The key has to contain the HTTP method and the resource name to be bound to the upstream.
Example:
export PROXY_GET_users='http://user_service'
export PROXY_PATCH_users='nsq://nsqd:4150/users'
With these environment variables:
GET call to /users/* will be routed to http://user_service;PATCH call to /users/* will be forwarded as a NSQ message to the NSQ broker on host nsqd:4150 with the topic users.This gateway is available in the public Docker registry as pierreprinetti/gateway.
version: '3'
services:
gateway:
image: pierreprinetti:gateway
environment:
PROXY_GET_users: 'http://user_service'
PROXY_PATCH_users: 'nsq://nsqd:4150/users'
depends_on:
- user_service
- nsqd
ports:
- '80:80'
The nsq connection string must have nsq as the protocol and be in the form:
nsq://host:port/topic
The incoming HTTP requests are packed in a JSON message containing the url and the body of the request.
Example:
{
"url": "/users/abc",
"body": "{\"first_name\":\"John\",\"age\":42}"
}
Content type
Image
Digest
Size
2.6 MB
Last updated
over 8 years ago
docker pull pierreprinetti/gateway