Resource icon

Scripted installation of Nextcloud 28 in iocage jail 2018-03-23

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I presume your router is acting as the DNS server for your LAN. If that's the case, it can likely be configured to return the internal IP address of your Nextcloud jail for the hostname of that jail--if nothing else, you can kludge around this by editing the hosts file on your client computer.
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
Having installed Nextcloud with the script, I am unable to reach Nextcloud from the inside and from the outside. Although the script indicated it was installed correct.
I read somewhere there might be a problem with caddy. What is the propper way to troubleshoot this?
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
Because I could not think of something better I executed remove-staging.sh as last past of the scripted installation of nextcloud:
This was the result:
sed: /usr/local/www/Caddyfile: no such file or directory
caddy does not exist in /etc/rc.d or the local startup
directories (/etc/ix.rc.d /usr/local/etc/rc.d), or is not executable


So there seems to be soming wrong with Caddy...
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
So there seems to be soming wrong with Caddy...
Almost certainly, which means there should be something in the script output indicating what happened.
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
I looked in different logs in ...nextcloud/root/var/log but could not find a lead to work on.
Edit:
In the Caddyfile I found:
log /var/log/nextcloud_access.log
errors /var/log/nextcloud_errors.log
But I could not locate these logs, they do not seem to exist...


Are there any specific logs in an other location to check?
Or is it wiser to just remove the jail in FreeNAS and run the script again?

I suspect pfsense might have blocked some traffic to Cloudflare but I think I fixed this by whitelisting the cloudflare IP-ranges in pfblocker ... If something was blocked by the firewall while running the script does that mean you have to run the script once again?
 
Last edited:

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
I ran the script again... same result :( (at least it profes that it is reproducible...)

This is what I see the caddy.log:
2019/11/29 11:37:59 [INFO] Caddy version: v1.0.4
2019/11/29 11:37:59 /usr/local/www/Caddyfile:9 - Error during parsing: Setting up DNS provider 'cloudflare': cloudflare: some credentials information are missing: CLOUDFLARE_EMAIL or some credentials information are missing: CLOUDFLARE_DNS_API_TOKEN,CLOUDFLARE_ZONE_API_TOKEN


I checked and double checked the nextcloud-config file but that looks ok... it is the global api key (which I copy pasted from the cloudflare site so no typy-errors..) from cloudflare that should be used right?

this is my nextcloud-config file:

JAIL_IP="192.168.30.67"
DEFAULT_GW_IP="192.168.30.1"
POOL_PATH="/mnt/xxxxxx"
TIME_ZONE="Europe/Amsterdam"
HOST_NAME="xxxxxx.eu"
DNS_CERT=1
CERT_EMAIL=xxxxxxxxxx@hotmail.com
DNS_PLUGIN="cloudflare"
DNS_ENV="CLOUDFLARE_EMAIL=xxxxxxxx@gmail.com
CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 
Last edited:

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
Since the switch to Caddy, I have never been able to make Nextcloud work on my system with my pfsense firewall through Haproxy. When I try to connect I get the white page. If I do not use pfsense and leave port 80 and 443 open, then it works. I think the issue is the lack of support for http2 from what I was able to read on.

@Apollo: did you get Nextcloud to work with the combination of HAProxy - Pfsense when you used the standard Nexcloud-plugin ? I also use pfsense since I am totally stuck with the script I am now looking at HAproxy as alternative to configure a setup with a reversed proxy setup...
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
it is the global api key (which I copy pasted from the cloudflare site so no typy-errors..) from cloudflare that should be used right?
Yes, that's right.
DNS_ENV="CLOUDFLARE_EMAIL=xxxxxxxx@gmail.com
CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
This should all be on one line--is it? It should look like:
Code:
DNS_ENV="CLOUDFLARE_EMAIL=xxxxxxxx@gmail.com CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
Somehow there was a line cut of... ,anyway I fixed it and made it one line again with nano in putty ... the shell in Freenas sometimes does strange things.

Do you I have to run the script again then?
 

Kryptonit3

Dabbler
Joined
Nov 20, 2019
Messages
10
Issue installing
Code:
root@freenas[...id10/scripts/freenas-iocage-nextcloud]# ./nextcloud-jail.sh
11.3-RELEASE-P5 was not found!
Failed to create jail
root@freenas[...id10/scripts/freenas-iocage-nextcloud]# iocage list -r
+---------------+
| Bases fetched |
+===============+
| 11.2-RELEASE  |
+---------------+
| 11.3-RELEASE  |
+---------------+
root@freenas[...id10/scripts/freenas-iocage-nextcloud]#


I see this is how you are getting the release variable RELEASE=$(freebsd-version | sed "s/STABLE/RELEASE/g")

When I run it manually I get
Code:
root@freenas[...id10/scripts/freenas-iocage-nextcloud]# freebsd-version | sed "s/STABLE/RELEASE/g"
11.3-RELEASE-p5


When I create a jail manually it shows this
1575135436374.png


Not sure the problem.

----- EDIT -----
I manually edited the script file. I changed line 151.
Before
Code:
if ! iocage create --name "${JAIL_NAME}" -p /tmp/pkg.json -r "${RELEASE}" ip4_addr="${INTERFACE}|${JAIL_IP}/24" defaultrouter="${DEFAULT_GW_IP}" boot="on" host_hostname="${JAIL_NAME}" vnet="${VNET}"

After
Code:
if ! iocage create --name "${JAIL_NAME}" -p /tmp/pkg.json -r "11.3-RELEASE" ip4_addr="${INTERFACE}|${JAIL_IP}/24" defaultrouter="${DEFAULT_GW_IP}" boot="on" host_hostname="${JAIL_NAME}" vnet="${VNET}"


Changed "${RELEASE}" to "11.3-RELEASE". Guess it doesn't like the -p5. It worked after changing that line. If you do this make sure you use the proper latest release on your system by running iocage list -r and using the newest one if more than one.
 
Last edited:

Kryptonit3

Dabbler
Joined
Nov 20, 2019
Messages
10
Hi,

down is more detailed view of my problem.



charlie@freenas:~ % cd freenas-iocage-nextcloud/ charlie@freenas:~/freenas-iocage-nextcloud % sudo ./nextcloud-jail.sh ls: /mnt/aja/db: No such file or directory 11.1-RELEASE was not found! Failed to create jail

Charlie, look at my post above if you are still having issues.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
the shell in Freenas sometimes does strange things.
Much better would be to use an SSH session. But what's probably going on is that, in the version/configuration on FreeNAS, nano automatically wraps long lines. The -w flag defeats this behavior.

Do you I have to run the script again then?
You shouldn't need to. In the jail, run sysrc caddy_env="CLOUDFLARE_EMAIL=xxxxxxxx@gmail.com CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" and then service caddy restart. That should do the trick.
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
You shouldn't need to. In the jail, run sysrc caddy_env="CLOUDFLARE_EMAIL=xxxxxxxx@gmail.com CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" and then service caddy restart. That should do the trick.
[/QUOTE]

The modification of the api_key as you described seemed to work!

Code:
service caddy restart
gives me this output:
Code:
caddy does not exist in /etc/rc.d or the local startup
directories (/etc/ix.rc.d /usr/local/etc/rc.d), or is not executable


Still stuck somehow…
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
Were you inside the jail when you ran the "service caddy restart"?
Certainly:
It was in … : /mnt/iocage/jails/nextcloud #
to be precise
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
No, not in the directory of the jail, inside the jail itself. Run "iocage console nextcloud", and then run the sysrc and the service caddy restart.
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
No, not in the directory of the jail, inside the jail itself. Run "iocage console nextcloud", and then run the sysrc and the service caddy restart.

hmm Excuse me.. I did not know the difference.

Inside the jail: this is what came out:
Code:
root@nextcloud:~ # service caddy restart
/etc/rc.conf: -env=CLOUDFLARE_EMAIL=xxxxxxxxx@xxxxxx.com CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: not found
/etc/rc.conf: -env=CLOUDFLARE_EMAIL=xxxxxxxxx@xxxxxx.com CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: not found
caddy not running? (check /var/run/caddy.pid).
Starting caddy.
CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CLOUDFLARE_EMAIL=xxxxxxxxxxxxxx@xxxxxx.com
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/
HOME=/
RC_PID=40724
CLOUDFLARE_EMAIL=xxxxxxxxxx@xxxxx.com
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/
CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
HOME=/
RC_PID=40724
/usr/local/etc/rc.d/caddy: WARNING: failed to start caddy
root@nextcloud:~ #
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
It's looking like the rc.conf is messed up. Still inside the jail, run nano -w /etc/rc.conf. You should see, probably as the last line, caddy_env="CLOUDFLARE_EMAIL=xxxxxxxx@gmail.com CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx". If that isn't there, fix it appropriately. If you have more than one caddy_env line, edit appropriately to make only one line.
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
You were right. The last lines were indeed messed up, I had to remove 2 lines.

After fixiing that, I ran service caddy restart again inside the jail:

Code:
root@nextcloud:~ # service caddy restart
caddy not running? (check /var/run/caddy.pid).
Starting caddy.
root@nextcloud:~ #


No errors so far...
 
Top