0

我能够在本地运行快速网关 Docker 容器和 Redis Docker 容器,并希望将其部署到 Azure。我该怎么做?

这是我的 docker-compose.yml 文件:

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:

这是我的 system.config.yml 文件:

# 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

这是我的 gateway.config.yml 文件:

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

挂载 YAML 文件然后点击 /ip 端点是我卡住的地方。

4

1 回答 1

1

根据您发布的配置文件,我想说0.0.0.0如果从容器运行,您需要指示 Express Gateway 进行侦听,否则它将无法列出到外部连接。

于 2019-10-31T14:56:56.777 回答