Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
39.3k stars 4.82k forks source link

502 with localhost as target_url #182

Closed montanaflynn closed 9 years ago

montanaflynn commented 9 years ago

Getting 502 from Kong when acting as a reverse proxy for a local service using localhost in the target_url. As you can see the service is up and running and works when added to Kong as 127.0.0.1 but when using localhost Kong returns a 502.

$ curl localhost:8001/apis/ | jq .
{
  "data": [
    {
      "created_at": 1430299086000,
      "name": "lwan",
      "target_url": "http://localhost:4444",
      "id": "2d27547e-5bd1-466c-c632-6ce4e68cb255",
      "public_dns": "lwan.com"
    },
    {
      "created_at": 1430299175000,
      "name": "lwan2",
      "target_url": "http://127.0.0.1:4444",
      "id": "1e07b7c5-d0c7-4354-c3b9-4083c59d8fd3",
      "public_dns": "lwan2.com"
    }
  ]
}

$ curl http://localhost:4444/hello
Hello, world!

$ curl http://localhost:8000/hello -H "host:lwan.com"
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty/1.7.10.2rc0</center>
</body>
</html>

$ curl http://localhost:8000/hello -H "host:lwan2.com"
Hello, world!
subnetmarco commented 9 years ago

The same problem might be related to #163 and may be caused by #127 - will look into it.

montanaflynn commented 9 years ago

I don't think it's related to #163 as that issue is using 127.0.0.1 and as far as I know only affects Kong running in docker. It may be related to #127, in fact there's another issue brought up in gitter chat that could also be related so I'll make an issue for that as well.

subnetmarco commented 9 years ago

This issue has been fixed and will be available in the next release of Kong.