# Scripted installation of Nextcloud 23 in an iocage jail

**URL:** <https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25>\
**Category:** How-to\
**Created:** [August 6, 2019, 2:55pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25 "2019-08-06T14:55:07Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [August 6, 2019, 2:55pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/1 "2019-08-06T14:55:07Z")

</div>

I’ve written a script to install Nextcloud 23 in an iocage jail under FreeNAS 11.3/TrueNAS 12.0. This script uses the [Caddy](https://caddyserver.com/) web server, which will manage Let’s Encrypt TLS certificates for you automatically. It creates the jail, installs and configures the web server, the database server, Nextcloud itself, and all its other dependencies. The script itself, and further instructions, are on GitHub:

> **[GitHub - danb35/freenas-iocage-nextcloud: Script to create an iocage jail on...](https://github.com/danb35/freenas-iocage-nextcloud)**
>
> Script to create an iocage jail on FreeNAS for the latest Nextcloud 20 release, including Caddy, MariaDB or PostgreSQL, and Let's Encrypt - GitHub - danb35/freenas-iocage-nextcloud: Script to c...

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [October 2, 2019, 10:18pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/2 "2019-10-02T22:18:43Z")

</div>

With the release of Nextcloud 17, I’ve created a new branch of this script to install that version. To try it out, run `git clone -b nextcloud-17 https://github.com/danb35/freenas-iocage-nextcloud.git`. It installs fine for me, but has had only minimal testing. I’ll probably merge this into master in a week or so if I don’t find or hear of any problems with it.

With this branch, I’ve also added a simple script to remove the Let’s Encrypt staging CA from your Caddyfile and obtain a trusted cert. See either the README or the end of the script’s output for more information.

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [October 14, 2019, 6:22pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/3 "2019-10-14T18:22:18Z")

</div>

I’ve made a few updates to the `nextcloud-17` branch, mainly to update the Caddyfiles for pretty URLs and to increase some timeouts. It looks like it’s working well and will probably be merged into master shortly. In testing, I’ve been able to upload files up to 15 GB through the web UI without any problems.

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [October 18, 2019, 1:21pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/4 "2019-10-18T13:21:12Z")

</div>

The `nextcloud-17` branch is now merged into `master`.

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [August 3, 2020, 11:34am UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/5 "2020-08-03T11:34:49Z")

</div>

Big changes to this one lately–with the release of Caddy v2, lots has been rewritten. Major changes to the script, Caddyfile, and even the rc script, but it seems to be working well.

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [December 10, 2021, 11:16am UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/6 "2021-12-10T11:16:28Z")

</div>

The changes last year continue to work well, and the script has now been updated to install Nextcloud 23.

---

<div class="post-metadata">

**Author:** ![JoaoKimoto](https://forum.freenas-community.org/letter_avatar_proxy/v4/letter/j/8c91f0/32.png) [@JoaoKimoto](https://forum.freenas-community.org/u/JoaoKimoto)\
**Post date:** [March 12, 2022, 9:05pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/7 "2022-03-12T21:05:24Z")

</div>

First, I would like to thank you for this great scrip, for sharing it with the community and keep it updated.

I have a home nextcloud iocage made by this script working perfectly for almost 3 years. I did the updates from inside the nextcloud only, but never run this scrip again.

A few days ago, a friend of mine couldn’t access it because of lets encrypt certificates, claiming it’s been revoked, despite many others still using the site with no problem at all.

My question is, does this scrip is aware of the existing iocage, can it run to update the installation without delete any data, and re-create the certification part?

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [March 12, 2022, 9:16pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/8 "2022-03-12T21:16:05Z")

</div>

The script is (now; not sure if it was at the time you installed it) aware of an existing installation, so it’s capable of installing over it if desired, but that shouldn’t be necessary here. What’s likely going on is that your cert got caught up in the mass TLS-ALPN revocation, and for some reason caddy hasn’t caught up with that yet. So to fix it, you’ll need to wipe out the old cert, so that Caddy will order a new one. To do this:

- Enter the jail with `iocage console nextcloud`
- `ls -aF` and see if you see a `.caddy` directory. If not, stop and post what you did find there.
- `service caddy stop`
- `mv .caddy caddy_old`
- `service caddy start`

In a matter of a few seconds, caddy should generate a new cert for you. You can check its validity using [ssllabs.com](http://ssllabs.com).

---

<div class="post-metadata">

**Author:** ![JoaoKimoto](https://forum.freenas-community.org/letter_avatar_proxy/v4/letter/j/8c91f0/32.png) [@JoaoKimoto](https://forum.freenas-community.org/u/JoaoKimoto)\
**Post date:** [March 13, 2022, 7:22pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/9 "2022-03-13T19:22:42Z")

</div>

Found this `/.config/caddy/autosave.json`. Is this the directory I should `mv` ?  
Found this `/usr/local/www/Caddyfile`. Maybe is from a older version of caddy.

Found out this on the first lines of `README.md`, from the git i pulled when i installed with your script:

_Script to create an iocage jail on FreeNAS for the latest Nextcloud 20 release, including Caddy 2.x, MariaDB 10.3/PostgreSQL 10, and Let’s Encrypt_

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [March 19, 2022, 1:44pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/11 "2022-03-19T13:44:24Z")

</div>

You shouldn’t need to rebuild Caddy to make this work, though that would ensure you were using the most up-to-date version of Caddy. But the `autosave.json` file doesn’t contain the cert data, so removing it won’t cause the certs to be regenerated. And my installation doesn’t put the Caddy data in `/.config`, so I’m not sure why yours does.

Let’s see where the certs are actually stored in your install–run `find / -name \*letsencrypt.org-directory`.

Also, what’s the output of `caddy version`?

---

<div class="post-metadata">

**Author:** ![bhizzle1121](https://forum.freenas-community.org/letter_avatar_proxy/v4/letter/b/ed655f/32.png) [@bhizzle1121](https://forum.freenas-community.org/u/bhizzle1121)\
**Post date:** [March 30, 2022, 3:41am UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/12 "2022-03-30T03:41:30Z")

</div>

Hi @danb35. I’ve been lurking around for a little over a month picking away at my first attempt at a truenas server and nextcloud.

I was able to install the original plugin and get it working on my lan. I then found your script. So, i blew away that jail and started over. Long story short, I successfully installed nextcloud and got a caddy cert with your script. I have my web address on cloudflare and pointed to my ipaddress.

I cannot for the life of me navigate to nextcloud in any way. 192.168.1.12 is what i set the lan ip to. I can ping it. I cannot even get the blue login screen. Entering my domain into a web browser routes me to my gateway login. (Though i believe that is because I’m doing it on my lan). If i do it from my phone it tries to go to my wan ipaddress but just never does anything.

I feel like im missing some obvious steps here that others may just inherently know. Any pointers?

---

<div class="post-metadata">

**Author:** ![danb35](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/danb35/32/14_2.png) [@danb35](https://forum.freenas-community.org/u/danb35)\
**Post date:** [April 15, 2022, 3:30pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/13 "2022-04-15T15:30:38Z")

</div>

> [@bhizzle1121](#):
>
> I feel like im missing some obvious steps here that others may just inherently know.

I think the part you may be missing is to have the FQDN you’ve set up for your Nextcloud instance point to that instance, from inside your LAN. So, if it’s called `cloud.yourdomain.net`, inside your LAN, `cloud.yourdomain.net` needs to resolve to the IP address of your jail. Usually, you’d set that up on your router. If your router is brain-damaged and can’t serve local DNS records like this, another possibility would be to set up something like [Pi-Hole](https://pi-hole.net/) as a local DNS server, and you can make that entry there.

---

<div class="post-metadata">

**Author:** ![djmysz](https://forum.freenas-community.org/user_avatar/forum.freenas-community.org/djmysz/32/123_2.png) [@djmysz](https://forum.freenas-community.org/u/djmysz)\
**Post date:** [July 27, 2023, 6:13pm UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/14 "2023-07-27T18:13:39Z")

</div>

Hi danb35, I followed the comment:

- Enter the jail with `iocage console nextcloud`
- `ls -aF` and see if you see a `.caddy` directory. If not, stop and post what you did find there.

did not find .caddy directory, found this:

 ![obraz](https://discourse-freenas-community.s3.dualstack.us-east-1.amazonaws.com/uploads/original/1X/d2165319f321323f9d3db77ee00d5384d87b6378.png)

How do I renew the certificate as I get emails from Let’s Encrypt that it needs renewal?

I did whole your scripted installation guide and it was amazing, everything is working, except renewing certificate automatically.

---

<div class="post-metadata">

**Author:** ![jmacias11](https://forum.freenas-community.org/letter_avatar_proxy/v4/letter/j/65b543/32.png) [@jmacias11](https://forum.freenas-community.org/u/jmacias11)\
**Post date:** [February 18, 2025, 2:47am UTC](https://forum.freenas-community.org/t/scripted-installation-of-nextcloud-23-in-an-iocage-jail/25/15 "2025-02-18T02:47:33Z")

</div>

Hello Dan, I appreciate all your support I’ve seen on this endeavor. I’m unfortunately having a problem with the installation. When I install it on the first attempt I get this error:

 ![image](https://discourse-freenas-community.s3.dualstack.us-east-1.amazonaws.com/uploads/original/1X/70e87adb971b297d9fdf5894813ead528affad08.png)

Here is my config file:  
JAIL\_IP=“192.168.1.71”  
DEFAULT\_GW\_IP=“192.168.1.1”  
POOL\_PATH="/mnt/Intersect1.0/"TIME\_ZONE=“America/New\_York”  
HOST\_NAME=“nextcloud.domain”  
DNS\_CERT=1  
DNS\_PLUGIN=“cloudflare”  
DNS\_TOKEN=“TOKEN”  
CERT\_EMAIL=“email”  
RELEASE=“13.3-RELEASE”

To be clear, I have proper values for domain, token, and email.

I’ll admit, I did have to slightly change the conditional that checks the release to get it to work with Release 13.3. I’ve been a while since I edited it so I don’t exactly remember the rationale there. If that’s the reason it doesn’t work shame on me.

Thank you!
