Can't get express-gateway to work with docker composeSee original GitHub issue
I am dealing with the following scenario:
- I have an authentication API
- I have an API that connects to a database
- I have an express-gateway API to handle rate limiting to the database API
The logic is as follows: go to localhost:3000/login (auth-api), login using Auth0, the user is then redirected to the gateway at localhost:8081, the gateway then rate limits and proxies the request to localhost:8000/path/to/data (database API)
Everything works correctly locally. However, now that I am trying to tie everything together using Docker compose. I keep receiving a Bad Gateway error when the gateway is supposed to redirect to the database API. I have included the code that redirects to the gateway, the docker-compose.yml file and the gateway.config.yml file to provide more context.
Database API Redirect
res.redirect('http://gateway:8081/path/to/data?token=' + req.query.code);
Gateway Config File
admin: port: 9876 hostname: localhost http: port: 8081 apiEndpoints: orders: host: 'gateway' # I have also tried to make this *, localhost and datasets-api and I have removed it completely paths: - '/path/to/data' # - '/' # - '*' serviceEndpoints: orders: url: 'http://datasets-api:8000' # I have also tried to make this localhost policies: - proxy - rate-limit - expression pipelines: orders: apiEndpoints: - orders policies: - expression: - action: jscode: " " - rate-limit: - action: max: 5 windowMs: 60000 - proxy: - action: serviceEndpoint: orders changeOrigin: true # I have also tried this as false
Docker Compose File
version: '3' services: dw-db: image: "centos/postgresql-95-centos7" environment: - POSTGRESQL_USER=admin - POSTGRESQL_PASSWORD=password - POSTGRESQL_DATABASE=db ports: - "6000:5432" datasets-api: build: "./datasets" hostname: datasets-api ports: - "8000:8000" environment: - HOSTNAME=datasets-api - CONFIG_PATH=/usr/src/app/server/config/config.json volumes: - $PWD/datasets:/usr/src/app depends_on: - dw-db links: - dw-db tty: true gateway: build: "./gateway" hostname: gateway environment: - HOSTNAME=gateway ports: - "8081:8081" - "9876:9876" depends_on: - datasets-api links: - datasets-api auth-api: build: "./gateway/auth-api" hostname: auth-api ports: - "3000:3000" environment: - HOSTNAME=auth-api - SERVICE_ENDPOINT=http://gateway:8081 # I have also tried to make this localhost but it makes no difference links: - gateway depends_on: - gateway
I have also submitted the issue on Gitter. Please could someone assist me with this?
Thanks in advance!
- Created 5 years ago
- Comments:10 (5 by maintainers)