In many cases, you want to run Tunnel to expose a multi-level subdomain, such as foo.bar.example.com. Because the certificate Tunnel generates will cover the first tier of subdomains and the apex (i.e. *.example.com and example.com), you need to make a small modification to how you run Tunnel to get it to work. Tunnel offers two ways to accomplish this:
The first option is for you to run Tunnel on a separate domain, and then CNAME the domain you wish to expose to that original Warped domain. How this works:
The reason why you need a custom solution to run Tunnel on a multi-level domain is because the certificate Tunnel generates for your origin server is not valid beyond one subdomain level.
In order to include more hostnames, you can bring your own TLS certificate. Below are instructions for how to use Tunnel with a custom certificate.
If you open the certificate file, you will see it has three sections: private key, certificate and Tunnel token. Later on you will replace the private key and certificate sections.
—–BEGIN PRIVATE KEY—– MIGHAgEAMBMwd51w/9Ne9nmMolCD0Z8s6AMBMwd51w/9Ne9nmMolCD0Z8s6 —–END PRIVATE KEY—– —–BEGIN CERTIFICATE—– MIIDKzCCAtCgAwIBAgIUfk7smiHna9wiBasCpbVyeg6vBRAwCgYIKoZIzj0EAwIw gY8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T YW4gRnJhbmNpc2NvvdWRmbGFyZS5jb20vb3JpZ2luX2Vj Y19jYS5jcmwwCgYIKoZIzj0EAwIDSQAwRgIhANZOIFV/kWzbHVbpmTYewL6hPEdC YgtWeoaU3x5WsnFQAiEAjYSW1LE1A0HjCzU0ZpEzElzo0YbVPbj57eaUV7gk+Tg= —–END CERTIFICATE—– —–BEGIN Tunnel TOKEN—– OWJkMDQ1ZTcxMDQ1ZWI2NTZhZmEwYzRiYTRkMjRhZjQKdjEuMC1kOWMyNTY4MmQ4 NTBkYzdjYTc1YzQ0ZlYjI5ZjIxNTU5NjhjOTE0MzY4YTkyYmUwODdhNzRj ZmEyMTU3Y2I5ZjU0MDMwMTczY2Q5MmQ3OTE0MWZkNWVmMTA5MGIxLTIxNjAxZjUz OWQwZjRlMjU3MDRjNmRhNzVjYTZjOTE3NmMwMDRhZGU4OTQ3NDIwOTE4Y2QyZGU2 N2ExMWNhNDE= —–END Tunnel TOKEN—–
Next you need to generate a certificate for your origin server. Cloudflare offers a free Certificate Authority for generating origin certificates that are only trusted by Cloudflare.
Login to the Cloudflare dashboard and visit the Crypto tab.
Scroll down to the section called Origin Certificates. In that table you will see certificates Tunnel generated for your server.
Click the button labeled ‘Create Certificate’.
When the modal opens, select the checkbox for “Let Cloudflare generate a private key and a CSR”. You may keep RSA selected as the key type. Then list the hostname you need to Warp, such as foo.bar.example.com.
Cloudflare will then present you a certificate to use for your origin.
Open up the file at ~/.cloudflared/cert.pem and replace the private key and certificate sections with the values Cloudflare shows in the dashboard.
Once you are finished, you can exit the modal in the dashboard by clicking ‘Ok’.
Note: If you use an encrypted certificate file, the Tunnel client won’t prompt for the passphrase and the certificate will not work.
You can now start Tunnel on a multi-level subdomain.
Note: you will also need a certificate for the connection from the client to Cloudflare’s edge. You manage this in the Edge Certificates section of the Crypto tab in the Cloudflare dashboard. By default, Cloudflare issues certificates for *.your-domain. If you need a certificate for a multi-level hostname, you can buy a dedicated certificate in the Cloudflare dashboard.