This repository contains the source code for a server that acts as a proxy for any number of other servers ("targets") running on the same host but different ports.
It allows for access to those targets from the same port (e.g. browser default 80
) but different domains (e.g. example.com
, api.example.com
, example.org
).
Configuration files and SSL certificates are managed by Park Ranger with the following configuration schema:
- ports
- http (number) - Port on which proxy should listen for HTTP requests
- https (number) - Port on which proxy should listen for HTTPS requests
- targets (array[Target]) – Targets with host values for matching requests
- defaultTarget (Target) - Default target without host value should targets with host values not match requests
- host (string) - Hostname for which proxy should listen for requests
- http (string) - Hostname to which proxy should route HTTP requests
- https (string) - Hostname to which proxy should route HTTPS requests
{
"ports": {
"http": 80,
"https": 443
},
"targets": [{
"host": "example.com",
"http": "example.com:1234",
"https": "example.com:5678"
}, {
"host": "example.org",
"https": "example.com:1234",
"https": "example.com:5678"
}, {
"host": "api.example.com",
"https": "example.com:9876"
}],
"defaultTarget": {
"http": "example.com:9191",
"https": "example.com:9192"
}
}
Deployment scripts are available through Hoist. The following are also supported:
npm run dev
: Runs the proxy and automatically reloads it when code changes are made during development