<commit_before># Auto SSL with Snaps

We now include the option to enable Caddy in your snap.  Caddy makes use of [Let's Encrypt](https://letsencrypt.org/) to automatically provide you SSL protection for your communications.

## Enabling Caddy

The first step is to generate some default configuration by running:

```
sudo rocketchat-server.initcaddy
```

Alternatively if you are on Debian or another distro:

```
sudo snap run rocketchat-server.initcaddy
```

Then, edit the Caddyfile found at: `/var/snap/rocketchat-server/current/Caddyfile`

It'll look like this out of the box:

```
http://:8080
proxy / localhost:3000 {
  websocket
  transparent
}
```

Replace `http://:8080` with your site information.  For instance, let's say I have example-domain.com pointing at my server. To get secured communications, I can do:

```
example-domain.com
proxy / localhost:3000 {
  websocket
  transparent
}
```

**Please note: using an IP address will not work for automatically enabling SSL. You must use a valid hostname ([here's why](https://caddyserver.com/docs/automatic-https)).**

Now you can restart the Caddy service by running:

```
sudo systemctl restart snap.rocketchat-server.rocketchat-caddy
```

You can check that the Caddy service started correctly by running:

```
sudo systemctl status snap.rocketchat-server.rocketchat-caddy
```

If everything went well, the site will be accessible at `https://example-domain.com`.

## Testing with an untrusted self-signed certificate

Simply add the `tls self_signed` directive to your Caddyfile like so:

```
https://example-domain.com<commit_msg>Update Snap Caddy Docs (#764)<commit_after># Auto SSL with Snaps

We now include the option to enable Caddy in your snap.  Caddy makes use of [Let's Encrypt](https://letsencrypt.org/) to automatically provide you SSL protection for your communications.

## Enabling Caddy

The first step is to generate some default configuration by running:

```
sudo rocketchat-server.initcaddy
```

Alternatively if you are on Debian or another distro:

```
sudo snap run rocketchat-server.initcaddy
```

Then, edit the Caddyfile found at: `/var/snap/rocketchat-server/current/Caddyfile`

It'll look like this out of the box:

```
http://:8080
proxy / localhost:3000 {
  websocket
  transparent
}
```

Replace `http://:8080` with your site information.  For instance, let's say I have example-domain.com pointing at my server.

First, be sure that your DNS has finished resolving before **before** attempting to enable SSL. If your DNS is not working yet, you could be instantly [throttled by Let's Encrypt](https://caddyserver.com/docs/automatic-https#testing) for _up to a week_. To test your DNS you can use http:

```
http://example-domain.com
proxy / localhost:3000 {
  websocket
  transparent
}
```

and restart caddy:

```
sudo systemctl restart snap.rocketchat-server.rocketchat-caddy
```

You can check that the Caddy service started correctly by running:

```
sudo systemctl status snap.rocketchat-server.rocketchat-caddy
```

Once that is tested and resolved, to get secured communications, you can remove the `http://`:

```
example-domain.com
proxy / localhost:3000 {
  websocket
  transparent
}
```

**Please note: using an IP address will not work for automatically enabling SSL. You must use a valid hostname ([here's why](https://caddyserver.com/docs/automatic-https)).**

Now you can restart the Caddy service by running:

```
sudo systemctl restart snap.rocketchat-server.rocketchat-caddy
```

You can check that the Caddy service started correctly by running:

```
sudo systemctl status snap.rocketchat-server.rocketchat-caddy
```

If everything went well, the site will be accessible at `https://example-domain.com`.

## Testing with an untrusted self-signed certificate

Simply add the `tls self_signed` directive to your Caddyfile like so:

```
https://example-domain.com
{'fraction_non_alphanumeric': 0.09690721649484536, 'fraction_numerical': 0.010051546391752578, 'mean_word_length': 4.497167138810198, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6540267', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1107, 'n_words': 453}