{"id":24081522,"url":"https://github.com/beh01der/docker-api-gateway-example","last_synced_at":"2025-09-07T10:35:06.539Z","repository":{"id":69196535,"uuid":"55108469","full_name":"Beh01der/docker-api-gateway-example","owner":"Beh01der","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-17T10:20:43.000Z","size":45,"stargazers_count":25,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T16:35:28.276Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://memz.co/api-gateway-microservices-docker-node-js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Beh01der.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-03-31T00:55:41.000Z","updated_at":"2023-03-08T23:39:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"69af6af9-4cac-491a-90cb-6c0024b5cf31","html_url":"https://github.com/Beh01der/docker-api-gateway-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Beh01der/docker-api-gateway-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beh01der%2Fdocker-api-gateway-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beh01der%2Fdocker-api-gateway-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beh01der%2Fdocker-api-gateway-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beh01der%2Fdocker-api-gateway-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Beh01der","download_url":"https://codeload.github.com/Beh01der/docker-api-gateway-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beh01der%2Fdocker-api-gateway-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274026710,"owners_count":25209739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-09T23:17:04.867Z","updated_at":"2025-09-07T10:35:06.525Z","avatar_url":"https://github.com/Beh01der.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-api-gateway-example\n\nThis project is a simple example of API Gateway pattern for [microservices](http://microservices.io/patterns/apigateway.html) implemented in Node.js.\n\nIt's **not production-ready** service and its sole purpose is to demonstrate usage of **node-docker-monitor** and **http-proxy** npm modules.\n\nService reacts on Docker events and as Docker containers go up and down, it creates or removes HTTP routing rules for them. \nTo indicate that a container is to be handled by the gateway it must have label **api_route** defining URL prefix for that container \nplus it must EXPOSE port that containerised service listens on. \n\n![Routing HTTP requests with API Gateway](docker-api-gateway.png)\n\nTo be able to monitor local Docker instance, we need to make UNIX socket `/var/run/docker.sock` available to the container.\n\n``` \ndocker run -d --name api-gateway -v /var/run/docker.sock:/var/run/docker.sock -p 80:8080 beh01der/docker-api-gateway-example\n```\n\nAn upstream service can be started with command similar to (depending on your service implementation)\n\n```\ndocker run -d --name service1 -e SERVICE_NAME=service1 -l=api_route='/service1' --expose 3000 beh01der/web-service-dockerized-example\n```\n\nWhen upstream service containers are being discovered we should see output like\n\n```\n$ docker logs api-gateway\nRegistered new api route: {\"apiRoute\":\"/service1\",\"upstreamUrl\":\"http://172.17.0.2:3000\"}\nRegistered new api route: {\"apiRoute\":\"/service2\",\"upstreamUrl\":\"http://172.17.0.3:3000\"}\n```\n\nNow, we can test it\n\n```\n$ curl 127.0.0.1/service1\nHello World!\nI am service 1!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeh01der%2Fdocker-api-gateway-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeh01der%2Fdocker-api-gateway-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeh01der%2Fdocker-api-gateway-example/lists"}