Skip to content

noppakorn-wai/micro-proxy

This branch is 5 commits ahead of dimapaloskin/micro-proxy:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f2761f2 · Jan 11, 2018

History

26 Commits
Nov 27, 2017
Nov 27, 2017
Jan 11, 2018
Nov 27, 2017
Dec 3, 2017
Jan 11, 2018
Nov 27, 2017
Jan 11, 2018
Dec 6, 2017
Jan 11, 2018

Repository files navigation

micro-proxy

Build Status

With micro-proxy, you can create a proxy server for your microservices based on now.sh path alias rules.

This is specially well suited for development to mirror the production configuration of multiple microservices and backends.

Usage

Firstly, install the package:

npm i -g micro-proxy

Then add following rules to a filename called rules.json:

{
  "rules": [
    {"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "http://localhost:5000"},
    {"pathname": "/**", "dest": "http://localhost:4000"}
  ]
}

Visit path alias documentation to learn more about rules.

Run the proxy server with:

micro-proxy -r rules.json -p 9000

Now you can access the proxy via: http://localhost:9000

Programmatic Usage

You can run the proxy programmatically inside your codebase. For that, add micro-proxy to your project with:

npm install micro-proxy

Then create the proxy server like this:

const createProxy = require('micro-proxy')
const proxy = createProxy([
  {"pathname": "/blog", "method":["GET", "POST", "OPTIONS"], "dest": "http://localhost:5000"},
  {"pathname": "/**", "dest": "http://localhost:4000"}
])

proxy.listen(9000, (err) => {
  if (err) {
    throw err
  }
  console.log(`> Ready on http://localhost:9000`)
})

Production Usage

You can use micro-proxy as a production deployment.

But if you are using ZEIT now, you can simply use path alias rules instead.
(It's a FREE service available for all ZEIT now deployments.)

About

Simplest proxy server for microservices

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%