|
| 1 | +# Custom Domain for Aleph Cloud Instance |
| 2 | + |
| 3 | +You can use Aleph Cloud Custom Domain Service to automatically handle a Domain Name for your instance. |
| 4 | + |
| 5 | +It not only ensures that the domain name is automatically linked to the DNS of your running VM but also provide transparent routing of webtraffic on IPv4. |
| 6 | + |
| 7 | +The Custom domain feature supports both IPv6 and IPv4, but they works in different way |
| 8 | + |
| 9 | +On IPv6 the custom domain will map directly to the publicly assigned address |
| 10 | +On IPv4, the instance receives no public address, thus the ip point to the hosting Compute Resource Node and can be |
| 11 | +used in two ways: |
| 12 | + |
| 13 | +* For HTTP, HTTPS (port 80 and 443). Request get automatically redirected to your instance via HAProxy, making it |
| 14 | + seamless for your users to connect to web server running instance your instance. |
| 15 | +* For other ports. We offer a port forwarding feature that allows routing port from inside your VM to a public port on |
| 16 | + the host. See [](../ipv4/ipv4-port-forwarding.md) |
| 17 | + |
| 18 | +# Configuration |
| 19 | + |
| 20 | +Setting up a custom domain for your decentralized instance with Aleph Cloud can be achieved with just a few steps, |
| 21 | +either through the CLI or the [Aleph Cloud Console](https://app.aleph.cloud) or manually by updating the aggregate. All |
| 22 | +methods will require an initial manual DNS configuration. |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +Before you start, make sure you have: |
| 27 | + |
| 28 | +- Access to your domain's DNS settings. |
| 29 | +- The Ethereum address you used to create the instance. |
| 30 | + |
| 31 | +## From the Aleph Cloud Console |
| 32 | + |
| 33 | +A custom domain name can be set upon instance creation, inside the Advanced Configuration Options section |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +If you want to add a domain to an existing Instance, you can do so via the Settings -> Domains -> Create Custom |
| 39 | +domain. |
| 40 | +There you can enter your domain name, then in the _Compute_ tab select your instance. The rest of the procedure is the |
| 41 | +same. |
| 42 | + |
| 43 | +Then go to the detail page of your instances and follow the instruction on how to configure your DNS Zone properly. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +If the domain is correctly set up, it will then display: **Properly configured** |
| 50 | + |
| 51 | + |
| 52 | +Note that due to multiple distributed layers of DNS caching, it may takes several hours for your new domain name to be |
| 53 | +available everywhere. |
| 54 | + |
| 55 | +## Test that the domain name is correct by |
| 56 | + |
| 57 | +On Unix system, you can check using the dig command: |
| 58 | + |
| 59 | +``` |
| 60 | +dig AAAA <yourdomain> |
| 61 | +``` |
| 62 | + |
| 63 | +or doing a ping. |
| 64 | + |
| 65 | +```bash |
| 66 | +ping -6 <yourdomain> |
| 67 | +``` |
| 68 | + |
| 69 | +For IPv4 |
| 70 | +```bash |
| 71 | +ping -6 <yourdomain> |
| 72 | +``` |
| 73 | + |
| 74 | +## via the CLI |
| 75 | + |
| 76 | +- The [aleph-client](https://github.com/aleph-im/aleph-client/) command-line tool is required.<br> |
| 77 | +- See [CLI Reference](/devhub/sdks-and-tools/aleph-cli/) or use `--help` for a quick overview of a specific command. |
| 78 | + |
| 79 | +All the domain commands are in the [`aleph domain` command subgroup](https://docs.aleph.cloud/devhub/sdks-and-tools/aleph-cli/commands/domain.html). |
| 80 | + |
| 81 | +The `aleph domain add` offer an interactive assistant that will guide you on the process of how to set up the instance name. |
| 82 | + |
| 83 | +You can also do each step manually |
| 84 | + |
| 85 | +## Manual DNS Setup |
| 86 | + |
| 87 | +Adding a custom domain to your Aleph Cloud instance involves: |
| 88 | + |
| 89 | +1. Attach the domain in your instance |
| 90 | +2. Creating a CNAME record. |
| 91 | +3. Creating a TXT owner proof record. |
| 92 | +4. Testing the domain setup. |
| 93 | + |
| 94 | + |
| 95 | +## Step 1: Attach the domain |
| 96 | +Use the command `aleph domain attach` or modify the `domain` key of your AGGREGATE. |
| 97 | +```bash |
| 98 | +aleph domain attach |
| 99 | +``` |
| 100 | + |
| 101 | +Example aggregate |
| 102 | +```json |
| 103 | +{ |
| 104 | + "domains": { |
| 105 | + "aleph1.yourdomain.com": { |
| 106 | + "type": "instance", |
| 107 | + "message_id": "ae1b726cad739ff13e4aea05fd035359e65429615d9223fd69fcc3d48e02a639", |
| 108 | + "updated_at": "2025-07-07T14:50:00.562Z", |
| 109 | + "programType": "instance" |
| 110 | + } |
| 111 | + } |
| 112 | +} |
| 113 | +``` |
| 114 | + |
| 115 | +## Step 2: Create a CNAME Record |
| 116 | + |
| 117 | +To add a custom domain, first, you need to create a CNAME record in your domain's DNS settings. The CNAME record will |
| 118 | +point your domain to your instance on Aleph Cloud. |
| 119 | + |
| 120 | +1. **Log into your domain provider's site.** |
| 121 | +2. **Navigate to your domain's DNS settings.** These settings are usually located in your domain control panel. |
| 122 | +3. **Create a new CNAME record.** |
| 123 | + - For the `Name/Host/Alias` field, enter your domain (i.e., `<<userdomain.com>>`). |
| 124 | + - For the `Value/Answer/Destination` field, enter `program.public.aleph.sh`. |
| 125 | + |
| 126 | +Your CNAME record should look something like this: |
| 127 | + |
| 128 | + NAME: <<userdomain.com>> |
| 129 | + VALUE: instance.public.aleph.sh |
| 130 | + |
| 131 | +Save your changes before moving on to the next step. |
| 132 | + |
| 133 | +## Step 3. Create a TXT Owner Proof Record |
| 134 | + |
| 135 | +Next, you need to create a TXT owner proof record in your domain's DNS settings. This record confirms that you own the |
| 136 | +domain associated with the Aleph Cloud instance. |
| 137 | + |
| 138 | +1. **Still in your domain's DNS settings, create a new TXT record.** |
| 139 | + - For the `Name/Host/Alias` field, enter `_control.<<userdomain.com>>`. |
| 140 | + - For the `Value/Answer/Destination` field, enter your Ethereum address (i.e., `<<public address>>`). |
| 141 | + |
| 142 | +Your TXT owner proof record should look something like this: |
| 143 | + |
| 144 | + NAME: _control.<<userdomain.com>> |
| 145 | + VALUE: <<public address>> |
| 146 | + |
| 147 | +Save your changes before moving on to the next step. |
| 148 | + |
| 149 | +## Step 4: Test the Domain Setup |
| 150 | + |
| 151 | +Check that you can ping the domain |
| 152 | + |
| 153 | + |
| 154 | +# Transparent IPv4 forwarding of HTTP and HTTPS |
| 155 | + |
| 156 | +On IPv4 HTTP traffic on both port 80 and 443 will be redirected from your domain name to your instance if you have a webserver running inside it and listening to it's outward ipv4 address. |
| 157 | + |
| 158 | +This is feature use [HaProxy](https://www.haproxy.com/) to listen on the CRN public IPv4 IP and detect which domain name is used and redirect the request to the appropriate instance. |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | +This functionality requires a CRN running aleph-vm version 1.7.0 or and higher and a manual setup from the Node operator. All |
| 163 | + |
| 164 | +You can test this is working inside your instance on http by launching a small webserver in python |
| 165 | +```bash |
| 166 | +sudo python -m http.server 80 |
| 167 | +``` |
| 168 | + |
| 169 | +::: warning |
| 170 | +Run this command in a new folder as it will expose all the file in the current folder on the internet. |
| 171 | +::: |
| 172 | + |
| 173 | +Then open in your browser http://yourdomain.com. |
| 174 | + |
| 175 | +If it works, then process to install a proper webserver to handle https:// for example Caddy or Nginx and run your intented application inside the VM. |
0 commit comments