Peet vd Westhuizen
Peet vd Westhuizen

Reputation: 403

How to deploy Express Gateway to Azure

I am able to run an express gateway Docker container and a Redis Docker container locally and would like to deploy this to Azure. How do I go about it?

This is my docker-compose.yml file:

version: '2'

services:
    eg_redis:
        image: redis
        hostname: redis
        container_name: redisdocker
        ports:
            - "6379:6379"
        networks:
            gateway:
                aliases:
                    - redis
    express_gateway:
        build: .
        container_name: egdocker
        ports:
            - "9090:9090"
            - "8443:8443"
            - "9876:9876"
        volumes:
            - ./system.config.yml:/usr/src/app/config/system.config.yml
            - ./gateway.config.yml:/usr/src/app/config/gateway.config.yml
        networks:
            - gateway

networks:
    gateway:

And this is my system.config.yml file:

# Core
db:
  redis:
    host: 'redis'
    port: 6379
    namespace: EG

# plugins:
  # express-gateway-plugin-example:
  #   param1: 'param from system.config' 

crypto:
  cipherKey: sensitiveKey
  algorithm: aes256
  saltRounds: 10

# OAuth2 Settings
session:
  secret: keyboard cat
  resave: false
  saveUninitialized: false
accessTokens:
  timeToExpiry: 7200000
refreshTokens:
  timeToExpiry: 7200000
authorizationCodes:
  timeToExpiry: 300000

And this is my gateway.config.yml file:

http:
  port: 9090
admin:
  port: 9876
  hostname: 0.0.0.0
apiEndpoints:
  # see: http://www.express-gateway.io/docs/configuration/gateway.config.yml/apiEndpoints
  api:
    host: '*'
    paths: '/ip'  
    methods: ["POST"]
serviceEndpoints:
  # see: http://www.express-gateway.io/docs/configuration/gateway.config.yml/serviceEndpoints
  httpbin:
    url: 'https://httpbin.org/'
policies:
  - basic-auth
  - cors
  - expression
  - key-auth
  - log
  - oauth2
  - proxy
  - rate-limit
  - request-transformer
pipelines:
  # see: https://www.express-gateway.io/docs/configuration/gateway.config.yml/pipelines
  basic:
    apiEndpoints:
      - api
    policies:
      - request-transformer:
        - action:
            body:
              add:
                payload: "'Test'"
            headers:
              remove: ["'Authorization'"]
              add:
              Authorization: "'new key here'"
      - key-auth:
      - proxy:
          - action:
              serviceEndpoint: httpbin
              changeOrigin: true

Mounting the YAML files and then hitting the /ip endpoint is where I am stuck.

Upvotes: 0

Views: 244

Answers (1)

Vincenzo
Vincenzo

Reputation: 1559

According to the configuration file you've posted I'd say you need to instruct Express Gateway to listen on 0.0.0.0 if run from a container, otherwise it won't be able to listed to external connections.

Upvotes: 1

Related Questions