{"user":"sinedied","name":"nano-gateway","namespace":"sinedied","repository_type":"image","status":1,"status_description":"active","description":" Lightweight API gateway for home-scale projects","is_private":false,"is_automated":false,"star_count":1,"pull_count":503,"last_updated":"2022-12-06T20:34:06.907149Z","last_modified":"2024-10-16T13:48:34.145251Z","date_registered":"2017-12-27T17:39:33.832843Z","collaborator_count":0,"affiliation":null,"hub_user":"sinedied","has_starred":false,"full_description":"# nano-gateway\n\n[![NPM version](https://img.shields.io/npm/v/nano-gateway.svg)](https://www.npmjs.com/package/nano-gateway) [![Build status](https://img.shields.io/travis/sinedied/nano-gateway/master.svg)](https://travis-ci.org/sinedied/nano-gateway) ![Node version](https://img.shields.io/badge/node-%3E%3D6.0.0-brightgreen.svg) [![Docker layers](https://images.microbadger.com/badges/image/sinedied/nano-gateway.svg)](https://microbadger.com/images/sinedied/nano-gateway) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n![](https://user-images.githubusercontent.com/593151/34394053-379cfa3c-eb57-11e7-855d-ef15cc5d3bcb.png)\n\n\u003e Lightweight API gateway for home-scale projects.\n\n**Features:**\n- Single-file YAML configuration\n- HTTPS support\n- Secure endpoints with API key\n- URL rewriting\n- Less than [50 LOC](index.js) :smile:\n\n## Installation\n\n```bash\nnpm install -g nano-gateway\n```\n\n## Usage\n```sh\nnanog --help\nUsage: nanog [--config file.yml] [--keygen]\n```\n\nUse the `nanog` command to start the gateway.\n\nBy default, it will use the `config.yml` configuration in the current working directory, but any file can be specified\nusing either the `NANO_GATEWAY_CONFIG` environment variable or the `--config` option.\n\nThe `--keygen` will generate a suitable API key to use in your configuration.\n\n## Configuration\n\nHere is an [example config.yml](config.yml) configuration:\n\n```yaml\nhttp:                 # optional, enable HTTP gateway\n  port: 8080          # optional, specify port for HTTP (default is 8080)\nhttps:                # optional, enable HTTPS gateway\n  cert: 'cert.pem'    # required, certificate path\n  key: 'privkey.pem'  # required, private key path\n  ca: 'chain.pem'     # optional, override trusted CA certificates\n  port: 8443          # optional, specify port for HTTPS (default is 8443)\nauth: true            # optional, enable API key authorization by default for all services\napiKey: '123456'      # required if auth is enabled, use nanog --keygen to generate a new key\nservices:             # required, define here the services to proxify\n  ip:                           # required, service name\n    path: '/ip'                 # required, endpoint(s) (use Express route syntax, see npmjs.com/path-to-regexp)\n    url: 'https://httpbin.org'  # required, target url for\n    auth: false                 # optional, authorization can be set or overriden by service\n  quote:                        # another service, add as many as you need\n    path: '/jokes/*'            # matches any routes under /jokes/\n    rewrite: '/jokes/random'    # optional, rewrite URL (for syntax, see npmjs.com/express-urlrewrite)\n    url: 'https://api.chucknorris.io'\n```\n\n### API key\n\nEndpoints secured by API key can be consumed either by using an `apiKey` query parameter:\n```sh\ncurl https://gateway.com/endpoint?apiKey=\u003cyour_api_key\u003e\n```\nor by using an `Authorization` header:\n```sh\ncurl -H \"Authorization: \u003cyour_api_key\u003e\" https://gateway.com/endpoint\n```\n\n\u003e Note: It is **strongly** recommended to use only HTTPS with API keys, otherwise your credentials will circulate in\n\u003e clear over the network and may be intercepted.\n\n### HTTPS\n\nTo enable HTTPS you need a valid SSL certificate.\n\nFree [LetsEncrypt](https://letsencrypt.org) certificates can be obtained using [certbot](https://certbot.eff.org).\n\nFor testing purposes, you can also generate a self-signed certificate using this command:\n```sh\nopenssl req -nodes -new -x509 -keyout privkey.pem -out cert.pem\n```\n\nAfter you have your certificate, use it in your configuration like this:\n```yaml\nhttps:\n  cert: 'cert.pem'\n  key: 'privkey.pem'\n  ca: 'chain.pem' # optional, override trusted CA certificates\n```\n\n## Running on Docker\n\nA minimal [Docker image](https://hub.docker.com/r/sinedied/nano-gateway/) based on `node:alpine` is also available\nfor deployment.\n\nYou just need to map a folder with a `config.yml` file in it to the `/config` volume:\n```\ndocker pull sinedied/nano-gateway\ndocker run --d -v \u003cyour_config_dir\u003e:/config -p 8443:8443 --name nano-gateway sinedied/nano-gateway\n```\n","permissions":{"read":true,"write":false,"admin":false},"media_types":["application/vnd.docker.container.image.v1+json"],"content_types":["image"],"categories":[],"immutable_tags_settings":{"enabled":false,"rules":[".*"]},"storage_size":725809806,"source":null}