gpt4 book ai didi

docker - 当我使用docker-compose运行时,Express网关始终返回Bad Gateway

转载 作者:行者123 更新时间:2023-12-02 20:35:57 24 4
gpt4 key购买 nike

我尝试将Express Gateway与Docker用作每个微服务的容器。到目前为止,它在本地测试方面一直非常出色。通过实现EG使用Docker时出现问题。我不知道问题出在哪里。 LOG_LEVEL = debug没有完整的描述。以前,我使用没有EG的docker,然后与其他微服务进行通信就很好了。请帮忙。

gateway.config.yml

http:
port: 8080
admin:
port: 9876
apiEndpoints:
authAPI:
host: '*' # i tried with egateway, localhost, 127.0.0.1 but still not working
paths:
- '/users/signin'
- '/users/signup'
- '/users/oauth/facebook'
- '/users/auth/google'
- '/users/auth/google/callback'
- '/users/secret'
- '/users/get-user-google'
- '/dashboard'
- '/test'
crudAPI:
host: '*'
paths:
- '/users/get-user-data'
- '/users/delete-user-data'
- '/users/add-user-data'
- '/users/get-one-user-data/*'
- '/users/update-user-data'
- '/users/update-pass-user-data'
serviceEndpoints:
authService:
url: 'http://localhost:3003'
crudService:
url: 'http://localhost:3004'
policies:
- log
- proxy
- jwt
- cors
- jwt-custom1
pipelines:
crud:
apiEndpoints:
- crudAPI
policies:
- cors:
- action:
origin: '*'
methods: 'GET, POST, PUT, DELETE'
allowedHeaders: 'X-Requested-With,content-type,Authorization'
credentials: true
- proxy:
- action:
serviceEndpoint: crudService
auth:
apiEndpoints:
- authAPI
policies:
- proxy:
- action:
serviceEndpoint: authService



docker-compose.yml
version: '3'

services:

egateway:
hostname: egateway
container_name: egateway
build: './test-eg2'
ports:
- "8080:8080"
depends_on:
- mongo
environment:
- LOG_LEVEL=debug

api-auth:
container_name: api-auth
build: './api-auth'
ports:
- "3003:3003"
links:
- mongo
- egateway

api-crud:
container_name: api-crud
build: './api-crud'
ports:
- "3004:3004"
links:
- mongo
- egateway

mongo:
container_name: mongo-dbx
image: mongo
ports:
- "27017:27017"

日志级别的结果=调试
enter image description here

我需要你的帮助。
感谢您审查此问题。

最佳答案

您用于auth-service和crud-service的URL不应是localhost。它应该是:

serviceEndpoints:
authService:
url: 'http://api-auth:3003'
crudService:
url: 'http://api-crud:3004'
api-authapi-crud将是docker-compose网络中这2个容器的主机名。

关于docker - 当我使用docker-compose运行时,Express网关始终返回Bad Gateway,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59387520/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com