Cloudflare Tunnels
This guide will show you how to use Cloudflare Tunnels for SnailyCAD. With Cloudflare Tunnels you can use a domain with an SSL certificate for your SnailyCAD instance.
Requirements
- A domain name with Cloudflare DNS
- A SnailyCAD instance
- A Cloudflare account
Getting started
1. Login to Cloudflare
- Navigate to the Cloudflare Zero Trust Dashboard and login with your Cloudflare account.
- in the dashboard under your account → Zero Trust (one.dash.cloudflare.com) → Networks → Tunnels
2. Create a tunnel for system
You are only able to create 1 tunnel per system.
- Click on
Create a Tunnel
- Enter a name for your tunnel (e.g.: "SnailyCAD Tunnel")
- Follow the instructions on the page to install Cloudflared on your server (Install Connector).
- Once connected, click
Next
3. Create Hostname for SnailyCAD API
-
Enter the configuration for your domain:
-
Subdomain: This is the subdomain you want to use for your SnailyCAD API. For example, if you want to use
cad-api.example.com
then you would entercad-api
here. -
Domain: The domain connected to your Cloudflare account. For example, if you want to use
cad-api.example.com
then you would enterexample.com
here. -
Path: Leave empty.
-
Service Type: Select
HTTP
-
URL:
localhost:8080
-
-
Click
Save Tunnel
-
Head back to the Tunnels dashboard.
4. Create Hostname for SnailyCAD Client
-
Click on the tunnel you just created
-
Click on the
Configure
button -
Navigate to the
Public Hostname
tab -
Click on
Add a public hostname
-
Enter the configuration for your domain:
-
Subdomain: This is the subdomain you want to use for your SnailyCAD API. For example, if you want to use
cad.example.com
then you would entercad
here. -
Domain: The domain connected to your Cloudflare account. For example, if you want to use
cad.example.com
then you would enterexample.com
here. -
Path: Leave empty.
-
Service Type: Select
HTTP
-
URL:
localhost:3000
-
-
Click
Save hostname
5. Configuring SnailyCAD
-
Open your SnailyCAD
.env
file.CORS_ORIGIN_URL
: Set this to your SnailyCAD Client domain. For example,https://cad.example.com
NEXT_PUBLIC_CLIENT_URL
: Set this to your SnailyCAD Client domain. For example,https://cad.example.com
NEXT_PUBLIC_PROD_ORIGIN
: Set this to your SnailyCAD API domain. For example:https://cad-api.example.com/v1
(Note: You need to add/v1
at the end of the URL)
-
All Done! 🎉