How to connect to a Service upstream that is behind Cloudflare?


I am trying to create a Service with upstream that sits behind Cloudflare. As we all know, Cloudflare blocks requests with direct IP access.

Here is the summary from Kong logs:

2018/08/21 16:58:30 [error] 55#0: *58 upstream timed out (110: Operation timed out) while connecting to upstream, client: <My-IP-address>, server: kong, request: “GET /some-path HTTP/1.1”, upstream: “http://<Cloudflare-IP-redacted>:80/some-path”, host: “<My-host-redacted>”

How can I resolve this?
Thanks in advance!

Any reason you’re trying to use an IP instead of a domain name in the upstream? Cloudflare typically hosts multiple services behind a shared IP and uses SNI to route the requests. You should just be able to define http://:80/some-path as your upstream.