{"action":"created","issue":{"url":"https://api.github.com/repos/Mashape/kong/issues/256","labels_url":"https://api.github.com/repos/Mashape/kong/issues/256/labels{/name}","comments_url":"https://api.github.com/repos/Mashape/kong/issues/256/comments","events_url":"https://api.github.com/repos/Mashape/kong/issues/256/events","html_url":"https://github.com/Mashape/kong/issues/256","id":78936030,"number":256,"title":"mesos-dns domain 502 bad gateway","user":{"login":"samek","id":125693,"avatar_url":"https://avatars.githubusercontent.com/u/125693?v=3","gravatar_id":"","url":"https://api.github.com/users/samek","html_url":"https://github.com/samek","followers_url":"https://api.github.com/users/samek/followers","following_url":"https://api.github.com/users/samek/following{/other_user}","gists_url":"https://api.github.com/users/samek/gists{/gist_id}","starred_url":"https://api.github.com/users/samek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samek/subscriptions","organizations_url":"https://api.github.com/users/samek/orgs","repos_url":"https://api.github.com/users/samek/repos","events_url":"https://api.github.com/users/samek/events{/privacy}","received_events_url":"https://api.github.com/users/samek/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Mashape/kong/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-05-21T10:36:13Z","updated_at":"2015-07-22T20:32:00Z","closed_at":"2015-06-19T19:14:06Z","body":"Hi, \r\nWe're using mesos to manage our cluster. We also use mesos-dns for service discovery.\r\n\r\nI've started kong in docker. \r\nCreated 2 apis (pointing to samek api server) one directly with target_url 10.0.0.200:3100 and one with (through haproxy) mesos-dns name haproxy.marathon.mesos \r\n\r\nI always get 502 bad gateway when using that domain. \r\n\r\nConf: \r\n curl localhost:8001/apis/ | jq .\r\n{\r\n  \"data\": [\r\n    {\r\n      \"created_at\": 1432203540000,\r\n      \"name\": \"testapi2\",\r\n      \"target_url\": \"http://haproxy.marathon.mesos:95/\",\r\n      \"id\": \"34942843-819f-4afe-ca40-17ed1f2bfc7e\",\r\n      \"public_dns\": \"test2\"\r\n    },\r\n    {\r\n      \"created_at\": 1432203430000,\r\n      \"name\": \"testapi\",\r\n      \"target_url\": \"http://10.0.0.200:31000/\",\r\n      \"id\": \"657ed867-7138-4686-c684-9ffba1de09fb\",\r\n      \"public_dns\": \"test\"\r\n    }\r\n  ]\r\n}\r\n \r\ncurl -i -X GET  --url http://localhost:8000/ --header 'Host: test2'\r\nHTTP/1.1 502 Bad Gateway\r\nServer: openresty/1.7.10.2rc0\r\nDate: Thu, 21 May 2015 10:31:28 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 182\r\nConnection: keep-alive\r\nVia: kong/0.2.1\r\n\r\n<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>openresty/1.7.10.2rc0</center>\r\n</body>\r\n</html>\r\n\r\nand direct with ip:\r\n curl -i -X GET  --url http://localhost:8000/ --header 'Host: test'\r\nHTTP/1.1 200 OK\r\nDate: Thu, 21 May 2015 10:31:43 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\nServer: nginx/1.4.6 (Ubuntu)\r\nX-Powered-By: PHP/5.5.9-1ubuntu4.7\r\nCache-Control: private, must-revalidate\r\npragma: no-cache\r\nexpires: -1\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS\r\nAccess-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Request-With, X-Requested-With\r\nAccess-Control-Allow-Credentials: true\r\nSet-Cookie: laravel_session=eyJpdiI6InBybWJWRFhETWw5Z0dtZCs5TkRsZVE9PSIsInZhbHVlIjoiYXI4OERcL0ljd1pXeHh6aVAzamN6MmxjVUtqMUVXZEphc3dwcGlkQjRmS1N6MGh0UHgrXC81U0dLYVJtQjVxQVR0MXM3TUxZMlJ0Vk43M3ljcWl5aXRDdz09IiwibWFjIjoiOGU5YjRiZjdiNTgwYjA2MjRiN2IzNDRmMDI5OGU2ZjI4YzM5MzY1ZTkwOWU2NGFlZGYyNjFkNjM5MWJlMzVmMCJ9; expires=Thu, 21-May-2015 12:31:43 GMT; Max-Age=7200; path=/; httponly\r\nVia: kong/0.2.1\r\n\r\n\"api?\"\r\n\r\n-----------------------------------------------------------------------------------------------------\r\n\r\nIf I go to the kong docker I can get the url which is reported as bad gateway. \r\n\r\ncurl -i  \"http://haproxy.marathon.mesos:95/\"\r\nHTTP/1.1 200 OK\r\nServer: nginx/1.4.6 (Ubuntu)\r\nContent-Type: text/html; charset=UTF-8\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\nX-Powered-By: PHP/5.5.9-1ubuntu4.7\r\nCache-Control: no-cache\r\nDate: Thu, 21 May 2015 10:33:34 GMT\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS\r\nAccess-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Request-With, X-Requested-With\r\nAccess-Control-Allow-Credentials: true\r\nSet-Cookie: laravel_session=eyJpdiI6IklqdWlcL3BFWGhFaU5DY1pqd1hiRVpBPT0iLCJ2YWx1ZSI6Ik5ydTRtR3VJWW81bFM0czkycUpCUmdyMXBTQ28wWUFKUTR4VFpIK0VkSUJjUkYrVEd2UkNVazBaSFViTFF4XC9zanNXbmgzdXFmZGFPeWZ1TGRHNjRZZz09IiwibWFjIjoiNzhmOWZhNmRiNmFkNDU3MDlhN2U1NTJiMTFlZjgyZjBkMTljNmJjYmNmM2FiZjQ5NjVhYjQ3YWEwNjNmNGM4MiJ9; expires=Thu, 21-May-2015 12:33:34 GMT; Max-Age=7200; path=/; httponly\r\n\r\n\"api?\"\r\n\r\n\r\n\r\n\r\nSo does Kong have a problem resolving domain .mesos since it's not a \"valid TLD\" one  in the real world? \r\n\r\n\r\n\r\n "},"comment":{"url":"https://api.github.com/repos/Mashape/kong/issues/comments/123853406","html_url":"https://github.com/Mashape/kong/issues/256#issuecomment-123853406","issue_url":"https://api.github.com/repos/Mashape/kong/issues/256","id":123853406,"user":{"login":"samek","id":125693,"avatar_url":"https://avatars.githubusercontent.com/u/125693?v=3","gravatar_id":"","url":"https://api.github.com/users/samek","html_url":"https://github.com/samek","followers_url":"https://api.github.com/users/samek/followers","following_url":"https://api.github.com/users/samek/following{/other_user}","gists_url":"https://api.github.com/users/samek/gists{/gist_id}","starred_url":"https://api.github.com/users/samek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samek/subscriptions","organizations_url":"https://api.github.com/users/samek/orgs","repos_url":"https://api.github.com/users/samek/repos","events_url":"https://api.github.com/users/samek/events{/privacy}","received_events_url":"https://api.github.com/users/samek/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T20:31:59Z","updated_at":"2015-07-22T20:31:59Z","body":"@thefosk It does work. \r\n\r\nI've started 5 nodes and  no gw timeout. Tomorrow I'll give it some traffic. \r\n\r\nanyway All I've added is those two options. \r\n\r\n    git diff\r\n    diff --git a/kong/cli/utils/signal.lua b/kong/cli/utils/signal.lua\r\n    index 46aee31..e89ab1d 100644\r\n    --- a/kong/cli/utils/signal.lua\r\n    +++ b/kong/cli/utils/signal.lua\r\n    @@ -195,7 +195,7 @@ local function start_dnsmasq(kong_config)\r\n \r\n       -- Start the dnsmasq\r\n       local file_pid = kong_config.nginx_working_dir..(stringy.endswith(kong_config.nginx_working_dir, \"/\")     and \"\" or \"/\")..constants.CLI.DNSMASQ_PID\r\n    -  local res, code = IO.os_execute(cmd..\" -p \"..kong_config.dnsmasq_port..\" --pid-file=\"..file_pid)\r\n    +  local res, code = IO.os_execute(cmd..\" -p \"..kong_config.dnsmasq_port..\" --pid-file=\"..file_pid..\" -N -o \")\r\n       if code ~= 0 then\r\n         cutils.logger:error_exit(res)\r\n       else\r\n\r\n\r\n"}}