Skip to content

help request: 502 Bad Gateway #8774

@unsw-luopan

Description

@unsw-luopan

Description

I run apisix, nacos and a flask service in the same docker network with different containers. Follow this tutorial "https://apisix.apache.org/zh/blog/2022/02/21/nacos-api-gateway/" to build an example. Then I curl apisix from my host computer and get 502 result. What's wrong with my configuration?

apisix conf:
......
discovery:
nacos:
host:
- "http://192.168.32.2:8848"
prefix: "/nacos/v1/"

Apisix route registry command:
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
"uri": "/nacos/*",
"upstream": {
"service_name": "algorithm-service",
"type": "roundrobin",
"discovery_type": "nacos"
}
}'

curl command:
curl -i http://127.0.0.1:9080/nacos/

apisix error log:
2023/02/01 08:38:03 [error] 47#47: *2642 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.32.1, server: _, request: "GET /nacos/ HTTP/1.1", upstream: "http://0.0.0.0:8085/nacos/", host: "127.0.0.1:9080"

apisix access log:
192.168.32.1 - - [01/Feb/2023:08:38:03 +0000] 127.0.0.1:9080 "GET /nacos/ HTTP/1.1" 502 229 0.001 "-" "curl/7.68.0" 0.0.0.0:8085 502 0.001 "http://127.0.0.1:9080"

Environment

APISIX version: 2.15.0
Nacos version: 2.2.0

Host: windows using docker desktop.
All containers running in the same docker network(subnet 192.168.32.0/20, gateway 192.168.32.1) which use bridge mode.
Flask service running at 0.0.0.0:8085 in one container and can be reached from other containers.
Curl running from my host computer (windows).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions