I am trying to create a APISIX gateway for my microservice. I have used the docker to install APISIX gateway using the apisix documentation Getting started (https://apisix.apache.org/docs/apisix/getting-started/README/) Version 3.3.0. It works for route:
curl -i "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
"id": "getting-started-ip",
"uri": "/ip",
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}'
and curl "http://127.0.0.1:9080/ip"
it returns the expected response.
Now i want to change the upstream to localhost:XXXX. I have my dummy api server running at localhost:XXXX (not on docker)
if i do curl "http://localhost:XXXX/api/v1/test_server/testing"
it returns back { success: true}
as json
now i want to change the apisix upstream as the dummy api server i.e. localhost:XXXX, so what did was change the upstream:
curl -i "http://127.0.0.1:9180/apisix/admin/routes" -X PUT -d '
{
"id": "1",
"uri": "/api/v1/test_server/testing",
"upstream": {
"type": "roundrobin",
"nodes": {
"localhost:XXXX": 1
}
}
}'
but when i try to do curl "http://127.0.0.1:9080/api/v1/test_server/testing"
it shows
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty</center>
<p><em>Powered by <a href="https://apisix.apache.org/">APISIX</a>.</em></p></body>
</html>
and in the docker log of APISIX it shows
connect() failed (111: Connection refused) while connecting to upstream, client: localhost, server: _, request: "GET /api/v1/test_server/testing HTTP/1.1", upstream: "http://localhost:XXXX/api/v1/test_server/testing", host: "<host ip and port>"
Can you help me why it not able to stablish connection to my local server.
Thanks in advance