Securely deliver applications with Cloud·续1

Figure 6: Connectivity from Cloudflare to origin server(s) via Cloudflare Network Interconnect (CNI)

The above diagram describes origin connectivity through Cloudflare Network Interconnect (CNI) ↗︎ which allows you to connect your network infrastructure directly with Cloudflare and communicate only over those direct links. CNI allows customers to interconnect branch and headquarter locations directly with Cloudflare. Customers can interconnect with Cloudflare in one of three ways: over a private network interconnect (PNI) available at Cloudflare peering facilities ↗︎, via an IX at any of the many global exchanges Cloudflare participates in ↗︎, or through one of Cloudflare’s interconnection platform partners ↗︎.

Cloudflare’s global network allows for ease of connecting to the network regardless of where your infrastructure and employees are.

Routing to the origin

Regardless of which connectivity model is used, DNS resolution is done first and provides Cloudflare the information of where to route to. Cloudflare can support configurations as an authoritative DNS provider, secondary DNS provider, or non-Cloudflare DNS (CNAME) setups for a zone. For Cloudflare performance and security services to be applied, the traffic must be routed to the Cloudflare network.

Example: Securing your application with Cloudflare Tunnel and Access

Securing connectivity with Cloudflare Tunnel

Although there are multiple ways to onboard an application to use Cloudflare services, a common approach is to use Cloudflare DNS as the primary authoritative DNS. The additional benefit for customers here is that Cloudflare is consistently ranked the fastest available authoritative DNS provider globally ↗︎.

In this example, we’ll connect our origin server to Cloudflare securely with Cloudflare Tunnel. You can configure DNS in the dashboard and enter the site you want to onboard. You’ll receive a pair of Cloudflare nameservers to configure at your domain registrar’s site. Once that’s completed, Cloudflare becomes the primary authoritative DNS provider.

If Cloudflare is configured for just routing over the Internet, the DNS configuration would look something like below, where the A record points to the IP address of the origin server or respective load balancer. As Cloudflare is acting as a reverse proxy, the status shows as Proxied." As is, Cloudflare is still acting as a reverse proxy so all the Cloudflare services such as CDN, WAF, and Access can be used.

Typical configuration for directing traffic through Cloudflare network.

Figure 7: DNS configuration for 'cftestsite3.com' - pointing to IP address of origin or load balancer.

We can also use Cloudflare Tunnel over the Internet to provide for more security and to prevent the need for opening any inbound firewall rules to the origin(s). In this way, instead of an A record in the DNS configuration, we will have a CNAME record pointing to the tunnel we deploy. Here we deploy a tunnel from the origin to the Cloudflare network, and the DNS will automatically be configured. A CNAME record that points to the tunnel will be created; this enforces all traffic going to the origin(s) be routed over the Cloudflare Tunnel.

To create and manage tunnels, you need to install and authenticate cloudflared on your origin server. cloudflared is what connects your server to Cloudflare’s global network.

There are two options for creating a tunnel - via the dashboard or via the command line. It’s recommended getting started with the dashboard, since it will allow you to manage the tunnel from any machine.

A remotely-managed tunnel only requires the tunnel token to run. Anyone with access to the token will be able to run the tunnel. You can get a tunnel’s token from the dashboard or via the API as shown below. The command provided in the dashboard will install and configure cloudflared to run as a service using an auth token.

In the Cloudflare dashboard, navigate to Zero Trust > Networks > Connectors. Select the "Create a tunnel" button, name the tunnel, and save.

Cloudflare allows for easily creating and naming a tunnel.

Figure 8: Cloudflare Tunnel Creation.

Next, you’ll be presented with a screen where you select the operating system (OS) of your origin server. You will then be provided a CLI command that you can run on your origin that will automatically download and install the Cloudflare Tunnel software.

Cloudflare supports tunnel deployment/configuration for all popular operating systems.

Figure 9: Instructions to install and run a connector.

Below, the CLI command has been run to download and install the Cloudflare Tunnel software.

Cloudflare supports easy deployment/configuration of Cloudflare Tunnel via CLI.

Figure 10: Downloading and installing Cloudflare Tunnel

The connector will now automatically be displayed as connected.

On successful configuration, Cloudflare displays the Connectors and status of connection to Cloudflare network.

Figure 11: Cloudflare Tunnel Connectors showing in dashboard.

In the dashboard, you can now continue with the next step which is to create the tunnel and map it to a service on the origin as shown below. In this case, all HTTPS traffic will be sent over the tunnel to the origin server.

Cloudflare Tunnel configuration allows for routing traffic to specific services running on the origin.

Figure 12: Cloudflare Tunnel Configuration.

You can now see in the dashboard that the tunnel has been created and is healthy.

Cloudflare provides health status of deployed tunnels.

Figure 13: Cloudflare Tunnel is created and healthy.

Further, if we look at the DNS configuration, we can see a DNS record was automatically created pointing to the tunnel ID. When you create a tunnel, Cloudflare generates a subdomain of cfargotunnel.com with the UUID of the created tunnel. Unlike publicly routable IP addresses, the subdomain will only proxy traffic for a DNS record in the same Cloudflare account. It’s not possible for another user to create a DNS record in another account or system to proxy traffic over this tunnel.

Cloudflare Tunnel automatically creates a CNAME DNS entry directing traffic to the deployed tunnel

Figure 14: Cloudflare DNS CNAME record automatically created

We now have secure application access. Users can only access the application through the tunnel connected to the Cloudflare network. Further, since Tunnel uses outbound connections to Cloudflare and any return traffic from an outbound connection will be allowed, no inbound firewall rule is required creating less overhead and more operational simplicity.

If you were to deploy the tunnel via CLI, after the tunnel install, you would also need to authenticate cloudflared on the origin server. cloudflared is what connects the server to Cloudflare’s global network. This authentication can be done with the cloudflared tunnel login command as shown below.

Cloudflare provides for easily authenticating Cloudflare Tunnel with a Cloudflare account.

Figure 15: Authenticating cloudflared on the origin server.

You’ll be asked to select the zone you want to add the tunnel to as shown below.

Cloudflare can enforce tunnel-only connections to a specific zone.

Figure 16: Adding Cloudflare Tunnel to a selected zone.

Next, you’ll authorize the tunnel for the zone.

Users must authorize the zone a tunnel connects to.

Figure 17: Authorizing the tunnel for a zone.

Finally, you should receive confirmation that a certificate has been installed allowing your origin to create a tunnel on the respective zone.

Cloudflare provides a confirmation on successfully installing a certificate to origin, allowing it to connect via Tunnel to the Cloudflare network.

Figure 18: Confirmation that certificate has been successfully installed.

Securing the application with Cloudflare Access

The current setup as described prior in this document is shown below, where the origin server(s) are connected to the Cloudflare network via Tunnel. Now, we can start to consume Cloudflare services.

Cloudflare behaves as a proxy where traffic is directed and performance and security services applied.

Figure 19: Web app securely connected to Cloudflare network for performance and security services.

Currently the origin is only accessible via Cloudflare Tunnel. Because a public hostname is used, access to the origin is public. The application is secured behind Cloudflare and protected from DDoS and other types of attacks. For additional security, Cloudflare Access can be used to place a layer of authentication and access controls in front of the tunneled application. Access enforces an authentication step before requests to the origin can be served. Many other identity, device and network attributes can be used in the policy, allowing customers to define access beyond just authentication. For example, customers can define the network the request originates from, as well as ensuring the user device is running the latest operating system.

Below, you can see an application has been created for cftestsite3.com.

Cloudflare Access allows for creating application policies to secure application access.