> ## Documentation Index
> Fetch the complete documentation index at: https://dos.dzaleka.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Domain Setup

> Configure a custom domain for your Dzaleka Online Services deployment

Connect a custom domain to your Netlify deployment to use your own domain name instead of the default Netlify subdomain.

## Overview

The production site uses the domain `services.dzaleka.com` as configured in `astro.config.mjs:13`:

```javascript theme={null}
site: 'https://services.dzaleka.com'
```

This guide will help you set up any custom domain for your deployment.

## Prerequisites

* A registered domain name (from any domain registrar)
* Access to your domain's DNS settings
* A deployed site on Netlify

## Adding a Custom Domain

<Steps>
  ### Add domain in Netlify

  1. Log in to your [Netlify dashboard](https://app.netlify.com)
  2. Select your site
  3. Go to **Site settings** → **Domain management**
  4. Click **Add custom domain**
  5. Enter your domain name (e.g., `services.dzaleka.com`)
  6. Click **Verify**

  ### Choose domain type

  You can add:

  **Apex domain** (root domain):

  ```
  dzaleka.com
  ```

  **Subdomain**:

  ```
  services.dzaleka.com
  ```

  **www subdomain**:

  ```
  www.dzaleka.com
  ```

  <Note>
    Netlify recommends using a subdomain like `www` or a custom subdomain for better performance and flexibility.
  </Note>

  ### Verify domain ownership

  If you don't own the domain on Netlify, you'll need to verify ownership:

  1. Netlify will provide a verification code
  2. Add a TXT record to your DNS with the code
  3. Wait for verification (can take up to 24 hours)
  4. Return to Netlify to complete setup
</Steps>

## DNS Configuration

Configure your DNS records based on your domain type.

### Option 1: Netlify DNS (Recommended)

The easiest method is to use Netlify DNS:

<Steps>
  ### Transfer DNS to Netlify

  1. In **Domain management**, click **Set up Netlify DNS**
  2. Review the DNS records that will be created
  3. Click **Verify**
  4. Netlify will provide nameservers

  ### Update nameservers

  1. Go to your domain registrar (GoDaddy, Namecheap, etc.)
  2. Find DNS/Nameserver settings
  3. Replace existing nameservers with Netlify's nameservers:
     ```
     dns1.p0X.nsone.net
     dns2.p0X.nsone.net
     dns3.p0X.nsone.net
     dns4.p0X.nsone.net
     ```
     (Replace `0X` with the actual values provided)
  4. Save changes

  ### Wait for propagation

  DNS changes can take 24-48 hours to fully propagate globally.
</Steps>

### Option 2: External DNS

If you prefer to keep DNS with your current provider:

#### For Subdomain (e.g., services.dzaleka.com)

Add a **CNAME record**:

| Type  | Name     | Value                 |
| ----- | -------- | --------------------- |
| CNAME | services | your-site.netlify.app |

Example for Cloudflare:

```
Type: CNAME
Name: services
Content: dzaleka-online.netlify.app
Proxy status: DNS only (gray cloud)
TTL: Auto
```

#### For Apex Domain (e.g., dzaleka.com)

Add an **A record** pointing to Netlify's load balancer:

| Type | Name | Value     |
| ---- | ---- | --------- |
| A    | @    | 75.2.60.5 |

<Warning>
  Netlify's IP address may change. Using Netlify DNS or a subdomain is more reliable for apex domains.
</Warning>

For better apex domain support, use an **ALIAS** or **ANAME** record if your DNS provider supports it:

| Type  | Name | Value                 |
| ----- | ---- | --------------------- |
| ALIAS | @    | your-site.netlify.app |

## SSL/HTTPS Setup

Netlify automatically provisions SSL certificates for custom domains.

### Automatic SSL Certificate

<Steps>
  ### Certificate provisioning

  After adding your domain:

  1. Netlify automatically requests an SSL certificate from Let's Encrypt
  2. This usually takes a few minutes
  3. You'll see the status in **Domain management** → **HTTPS**

  ### Verify HTTPS

  Once provisioned:

  1. Visit your domain with `https://`
  2. Check for the padlock icon in your browser
  3. Certificate is valid and automatically renews

  ### Force HTTPS redirect

  Ensure all HTTP traffic redirects to HTTPS:

  1. Go to **Domain management** → **HTTPS**
  2. Enable **Force HTTPS redirect**
  3. All `http://` requests will redirect to `https://`
</Steps>

### Troubleshooting SSL

**Certificate not provisioning**:

* Verify DNS records are correct
* Wait 24-48 hours for DNS propagation
* Check for CAA records blocking Let's Encrypt

**Mixed content warnings**:

* Ensure all resources (images, scripts) use HTTPS
* Update hardcoded `http://` URLs to `https://`
* Use protocol-relative URLs: `//example.com/image.jpg`

## Domain Redirects

Configure domain redirects for common scenarios.

### www to non-www (or vice versa)

Add both domains to Netlify, and Netlify will automatically redirect the secondary domain to the primary.

**Example**: Redirect `www.dzaleka.com` to `dzaleka.com`:

1. Add both `dzaleka.com` and `www.dzaleka.com`
2. Set `dzaleka.com` as the primary domain
3. Netlify automatically redirects `www` to non-`www`

### Custom redirects

Add custom redirects in `netlify.toml`:

```toml title="netlify.toml" theme={null}
# Redirect old domain to new domain
[[redirects]]
  from = "https://old-domain.com/*"
  to = "https://services.dzaleka.com/:splat"
  status = 301
  force = true

# Redirect specific path
[[redirects]]
  from = "/old-path"
  to = "/new-path"
  status = 301
```

## DNS Verification Tools

Use these tools to verify your DNS configuration:

### Check DNS records

```bash theme={null}
# Check A record
dig dzaleka.com A

# Check CNAME record
dig services.dzaleka.com CNAME

# Check nameservers
dig dzaleka.com NS
```

### Online tools

* [DNS Checker](https://dnschecker.org) - Check global DNS propagation
* [What's My DNS](https://www.whatsmydns.net) - DNS propagation checker
* [MX Toolbox](https://mxtoolbox.com/DNSLookup.aspx) - DNS lookup tool

## Email Configuration

If you use email with your domain, preserve your email records:

### MX Records

Preserve existing MX records when transferring DNS:

```
Type: MX
Name: @
Priority: 10
Value: mail.example.com
```

### SPF Records

Maintain SPF records for email authentication:

```
Type: TXT
Name: @
Value: v=spf1 include:_spf.google.com ~all
```

### DKIM Records

Keep DKIM records if configured:

```
Type: TXT
Name: default._domainkey
Value: v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3...
```

## Updating Site Configuration

After setting up your domain, update your site configuration:

<Steps>
  ### Update astro.config.mjs

  Change the `site` URL to your custom domain:

  ```javascript title="astro.config.mjs" theme={null}
  export default defineConfig({
    site: 'https://your-custom-domain.com',
    // ... other config
  });
  ```

  ### Update sitemap and robots.txt

  Regenerate your sitemap with the new domain:

  <CodeGroup>
    ```bash npm theme={null}
    npm run generate-sitemap
    ```

    ```bash yarn theme={null}
    yarn generate-sitemap
    ```

    ```bash pnpm theme={null}
    pnpm generate-sitemap
    ```
  </CodeGroup>

  ### Commit and deploy

  Push changes to trigger a new deployment:

  ```bash theme={null}
  git add astro.config.mjs
  git commit -m "Update site URL to custom domain"
  git push
  ```
</Steps>

## Testing Your Domain

Verify everything works correctly:

<Steps>
  ### Test HTTPS

  Visit your domain with HTTPS:

  ```
  https://your-domain.com
  ```

  Verify:

  * Page loads correctly
  * SSL certificate is valid
  * No mixed content warnings

  ### Test redirects

  Test HTTP to HTTPS redirect:

  ```
  http://your-domain.com
  ```

  Should redirect to:

  ```
  https://your-domain.com
  ```

  ### Test subpaths

  Verify all routes work:

  ```
  https://your-domain.com/events
  https://your-domain.com/services
  https://your-domain.com/about
  ```

  ### Test functions

  Verify serverless functions work:

  ```bash theme={null}
  curl -X POST https://your-domain.com/.netlify/functions/submit-voice \
    -H "Content-Type: application/json" \
    -d '{"title": "Test"}'
  ```
</Steps>

## Common Issues

### DNS not propagating

**Symptoms**: Domain not resolving or showing old site

**Solutions**:

* Wait 24-48 hours for full propagation
* Clear your DNS cache: `sudo dscacheutil -flushcache` (macOS)
* Try accessing from a different network
* Use incognito/private browsing mode

### SSL certificate not provisioning

**Symptoms**: "Not secure" warning or no HTTPS

**Solutions**:

* Verify DNS records point to Netlify
* Wait for DNS propagation
* Check for conflicting CAA records
* Contact Netlify support if issue persists

### Domain showing Netlify default page

**Symptoms**: Generic Netlify page instead of your site

**Solutions**:

* Verify domain is added in Netlify dashboard
* Check that DNS records are correct
* Ensure site is deployed successfully
* Clear browser cache

## Next Steps

<CardGroup cols={2}>
  <Card title="Netlify Deployment" icon="rocket" href="/deployment/netlify">
    Learn more about Netlify deployment options
  </Card>

  <Card title="Configuration" icon="gear" href="/deployment/configuration">
    Customize your Astro and Tailwind configuration
  </Card>
</CardGroup>
