reverse http proxy
Tired of CORS issues? This is a solution for you! This proxy server allows you to serve your content and someones apis from a single host eliminating need of CORS headers.
What is it?
eyjafjallajokull is a reverse proxy. In few words: it's an http server that diverts requests to other other http servers(endpoints).
How to use it?
1. Add your endpoints to a config file
Config is a json formatted list of routes. By default eyjafjallajokull looks for a routes.json in current directory to get routes configuration.
Route properties are:
hostnameproperty will defines a value forHostheaderendpointis a url to a server that will respond to requestspathis a regex pattern for request routing by URI
Let's say:
- Your grunt(or other) server lives at
localhost:9000 - API that you want to use lives at
derpeddit.herokuapp.com - APIs that
derpeddit.herokuapp.comprovides start with a prefix/api
Here's how a config will look like:
[
{ "path":"/api",
"endpoint":"https://derpeddit.herokuapp.com",
"hostname": "derpeddit.herokuapp.com"
},
{ "path":"/",
"endpoint":"http://localhost:9000",
"hostname":"localhost:9000"
}
]2. Run proxy
./eyjafjallajokul -h
-listen-address="127.0.0.1": address to bind reverse proxy
-listen-port="8999": port to bind reverse proxy
-routes="routes.json": path to config file
./eyjafjallajokul -routes="/path/to/routes" -listen-address="127.0.0.1" -listen-port="8999"
Et voila! Access your server at localhost:8999