Resource icon

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

nikinp

Contributor
Joined
Sep 7, 2014
Messages
116
Yes, I do want to access from outside the LAN. I know my public IP address and the IP address of the Jail.
Do I need to put my public IP address into the cloudflare DNS settings, and if so, which one (there is A, CNAME, MX...). Or is it something else.
I didnt read any mention of port forwarding in the guide. So not sure what that requires.
Also, not sure where the IP address of the jail fits into all this.

Thanks for your patience!
 

nikinp

Contributor
Joined
Sep 7, 2014
Messages
116
That depends. Do you want to access the Nextcloud installation from outside your LAN? If not, then no, there's really nothing you need to do on that end (if yes, then you'd need to point the domain name to your IP address and forward ports to the Nextcloud jail). What you do need to do is what we've been discussing--figure out, on your network, with your devices, how to have X.com resolve to the IP address of your jail.
I cannot access it over the LAN either. I was expecting that the if I use browser to go to https://JAIL_IP that I would get nextcloud interface. But I get

This site can’t provide a secure connection
192.168.0.19 sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

I do get a response to ping on that IP address

It seems like someone else has noted something similar on the github page: https://github.com/danb35/freenas-iocage-nextcloud/issues/160
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,457
I was expecting that the if I use browser to go to https://JAIL_IP that I would get nextcloud interface.
You should not have been expecting this. As I've said several times up-thread (at least a couple of which were directly to you), and say in the docs, the hostname of your instance needs to resolve to your jail. Figure that out.
It seems like someone else has noted something similar on the github page: https://github.com/danb35/freenas-iocage-nextcloud/issues/160
Apparently they aren't any better at reading the docs. I really don't think this is a complicated concept.
 

nikinp

Contributor
Joined
Sep 7, 2014
Messages
116
You should not have been expecting this. As I've said several times up-thread (at least a couple of which were directly to you), and say in the docs, the hostname of your instance needs to resolve to your jail. Figure that out.

Apparently they aren't any better at reading the docs. I really don't think this is a complicated concept.
Dear Danb35,
Thank you again for your patience! As per your suggestion, (after many hours of head against screen bashing!) I have 'figured out' the resolving of hostname to the jail on the lan. In my case, I do not have the supported router/cannot upgrade firmware/pi hole, I had to do the last resort to editing the hosts file. Since you have labelled this a last resort, do you have any concerns using this approach?

As I posted on the github issue, I was getting the too many ERR_SSL_PROTOCOL_ERROR errors. As per your suggestion on that time, I had to disable cloudflare proxy. With it disabled, I could get to the login page of nextcloud from outside LAN and inside LAN.

I subsequently used the command to switch to the production server for the certificate to get a HTTPS connection. Are there any downsides to disabling the proxy?

Otherwise, thank you again for this resource and patience in answering my very inexperienced questions!
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,457
Since you have labelled this a last resort, do you have any concerns using this approach?
The biggest downside is that you need to make that same change on every device that you want to use to access your Nextcloud instance. DNS really is a better way to do this, and you probably could run Pi-Hole, though it would need to be in a VM rather than a jail (or just get a Raspberry Pi, which is what it was originally designed for).

As to the Cloudflare proxy, when enabled, it caches data and can speed up your site. For something as dynamic as Nextcloud, this is unlikely to provide any real benefit--save it for your static web sites.
 

InGenetic

Contributor
Joined
Dec 18, 2013
Messages
183
Hi again mr.Danb35,

i want to ask about memory leak in freenas , i'm using nextcloud in jail as in this tutorial,
my freenas using 16GB of RAM , and only for nextcloud on freenas.

hm.. about 1-2 months ago, i see my freenas run out the memory , the memory ram can only left 0.2gb , if its happen , its too slow respon to login to nextcloud, so i have to restart the freenas, and it'll normal again.

sometimes it will be run out memory in 1 week, but sometimes , just 2-3 days the memory become run out .

for ex:

View attachment 41667

and sometimes if freenas running out memory , my nextcloud can not be accessible. if it so , i have to restart the freenas and the nextcloud being normally again .

like below after restart freenas machine :

View attachment 41669

Please advice.

Regards,
Hi mr.Danb35 and all,

so sorry to bringing up the old post, my nextcloud sometimes is unable to access , it said "502 Bad Gateway",
when i check to freenas dashboard at that moment, i saw that memory free only 0.2 GB left ( for only 2-3 days freenas uptime ) i dunno , is it related to my freenas ram memory ?
this time , when it happening, i've to restart the freenas machine, and the nextcloud back to normal again , it always happening again after 2-3 days uptime.

i just restarted the freenas machine this morning, and after 8 hours later, now the ram free only 1.2GB left .

CPU.JPG


ram free.JPG


usually if the free ram only 0.2 GB left , my nextcloud will be unable to access it will said "502 Bad Gateway" again.

please advice , how to solve this problem .

Thank you very much.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,740
First of all you should try to find out which process is using all that memory. Before you reboot
  • log in to your NAS via SSH
  • enter top -j <ENTER>
  • type o
  • enter size <ENTER>
  • type q
Copy and paste the output here in a code block like this:
Code:
last pid: 48197;  load averages:  1.42,  0.90,  0.79                                                       up 12+19:15:50  11:15:35
168 processes: 1 running, 167 sleeping
CPU:  0.6% user,  0.0% nice,  0.8% system,  0.2% interrupt, 98.4% idle
Mem: 4020M Active, 33G Inact, 22G Wired, 3042M Free
ARC: 15G Total, 5827M MFU, 7565M MRU, 32M Anon, 661M Header, 1642M Other
     11G Compressed, 17G Uncompressed, 1.51:1 Ratio
Swap: 16G Total, 16G Free

  PID   JID USERNAME    THR PRI NICE   SIZE    RES STATE    C   TIME    WCPU COMMAND
75360     0 root         14  20    0  8246M  8052M kqread   9 807:46   3.83% bhyve
 3918     0 root         12  20    0  8217M  4669M kqread   1 784:09   3.00% bhyve
 4006     0 root         12  20    0  8217M  4635M kqread   4  17.4H   6.01% bhyve
 7863    20   1000       71  52    0  4143M  1235M uwait    7 175:08   2.14% java
 4248     0 root         12  20    0  4119M  3583M kqread  14 221:40   0.49% bhyve
 4224     0 root         11  20    0  4119M  2368M kqread  11 406:26   0.64% bhyve
78338    22     88       46  20    0  1977M   453M select  15   6:18   0.06% mysqld
19327     9     88       42  20    0  1830M   465M select  15  29:51   0.05% mysqld
57979    23     88       45  20    0  1787M   385M select  10   1:46   0.04% mysqld
46013     0 root         37  52    0  1582M  1193M kqread  11 256:08   0.00% python3.8
57985    23    211       23  21    0  1389M   608M uwait    8  50:59   0.36% gitea
22022    11    907       34  20    0  1240M   414M uwait   15  93:05   1.31% influxd
67260    11    904       24  20    0   830M   102M uwait   15   1:01   0.10% grafana-server
 7477    20 root         11  20    0   304M    79M kqread   8  14:52   0.35% node
 

InGenetic

Contributor
Joined
Dec 18, 2013
Messages
183
First of all you should try to find out which process is using all that memory. Before you reboot
  • log in to your NAS via SSH
  • enter top -j <ENTER>
  • type o
  • enter size <ENTER>
  • type q
Copy and paste the output here in a code block like this:
Code:
last pid: 48197;  load averages:  1.42,  0.90,  0.79                                                       up 12+19:15:50  11:15:35
168 processes: 1 running, 167 sleeping
CPU:  0.6% user,  0.0% nice,  0.8% system,  0.2% interrupt, 98.4% idle
Mem: 4020M Active, 33G Inact, 22G Wired, 3042M Free
ARC: 15G Total, 5827M MFU, 7565M MRU, 32M Anon, 661M Header, 1642M Other
     11G Compressed, 17G Uncompressed, 1.51:1 Ratio
Swap: 16G Total, 16G Free

  PID   JID USERNAME    THR PRI NICE   SIZE    RES STATE    C   TIME    WCPU COMMAND
75360     0 root         14  20    0  8246M  8052M kqread   9 807:46   3.83% bhyve
3918     0 root         12  20    0  8217M  4669M kqread   1 784:09   3.00% bhyve
4006     0 root         12  20    0  8217M  4635M kqread   4  17.4H   6.01% bhyve
7863    20   1000       71  52    0  4143M  1235M uwait    7 175:08   2.14% java
4248     0 root         12  20    0  4119M  3583M kqread  14 221:40   0.49% bhyve
4224     0 root         11  20    0  4119M  2368M kqread  11 406:26   0.64% bhyve
78338    22     88       46  20    0  1977M   453M select  15   6:18   0.06% mysqld
19327     9     88       42  20    0  1830M   465M select  15  29:51   0.05% mysqld
57979    23     88       45  20    0  1787M   385M select  10   1:46   0.04% mysqld
46013     0 root         37  52    0  1582M  1193M kqread  11 256:08   0.00% python3.8
57985    23    211       23  21    0  1389M   608M uwait    8  50:59   0.36% gitea
22022    11    907       34  20    0  1240M   414M uwait   15  93:05   1.31% influxd
67260    11    904       24  20    0   830M   102M uwait   15   1:01   0.10% grafana-server
7477    20 root         11  20    0   304M    79M kqread   8  14:52   0.35% node
Hi mr. Patrik ,

about my freenas machine , 4 hours ago , the free mem still 9.0 GB ,
now is about 0.8 GB , i'm pretty sure if it's going to 0.2 GB , my nextcloud will be cannot be accessed.

cloud1.JPG

cloud2.JPG


here the process :

last pid: 28746; load averages: 0.48, 0.51, 0.54 up 0+19:57:28 21:49:42
66 processes: 1 running, 65 sleeping
CPU: 2.6% user, 0.0% nice, 0.5% system, 0.0% interrupt, 97.0% idle
Mem: 305M Active, 1500M Inact, 13G Wired, 851M Free
ARC: 11G Total, 7131M MFU, 3251M MRU, 539K Anon, 61M Header, 653M Other
9655M Compressed, 16G Uncompressed, 1.65:1 Ratio
Swap: 2048M Total, 2048M Free

PID JID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
2326 1 88 38 20 0 579M 243M select 0 9:07 1.46% mysqld
77 0 root 38 20 0 284M 243M kqread 1 2:20 0.64% python3.7
28694 1 www 1 22 0 235M 69320K accept 2 0:05 1.35% php-fpm
28692 1 www 1 22 0 233M 65368K nanslp 3 0:06 6.31% php-fpm
28719 1 www 1 22 0 229M 63648K accept 1 0:02 1.24% php-fpm
2189 1 root 1 20 0 217M 31100K kqread 3 0:01 0.00% php-fpm
139 0 root 3 20 0 188M 141M piperd 3 0:08 0.00% python3.7
1372 0 root 15 20 0 172M 137M umtxn 2 0:06 0.51% uwsgi-3.7
137 0 root 3 20 0 169M 139M usem 0 0:08 0.00% python3.7
136 0 root 3 20 0 167M 139M usem 1 0:08 0.00% python3.7
135 0 root 3 20 0 167M 139M usem 0 0:08 0.00% python3.7
138 0 root 3 20 0 167M 139M usem 1 0:08 0.00% python3.7
1177 0 root 1 20 0 162M 146M select 2 0:02 0.00% smbd
1286 0 root 1 20 0 126M 105M kqread 2 0:03 0.00% uwsgi-3.7
1209 0 root 1 20 0 120M 104M select 3 0:00 0.00% smbd
1208 0 root 1 20 0 120M 104M select 2 0:00 0.00% smbd
2224 1 root 38 20 0 116M 29176K uwait 3 1:01 0.70% caddy
2334 0 root 11 20 0 85976K 53708K nanslp 0 3:48 0.00% collectd
1511 0 root 1 52 0 71136K 63252K ttyin 1 0:01 0.00% python3.7
1089 0 root 3 21 0 56944K 44132K select 1 5:48 0.04% python3.7
1074 0 daemon 1 20 0 50640K 33364K kqread 2 0:01 0.00% python3.7
1211 0 root 1 20 0 39320K 22912K select 0 0:00 0.00% winbindd
1210 0 root 1 20 0 38840K 23708K select 0 0:00 0.00% winbindd
1212 0 root 1 20 0 38048K 23000K select 1 0:00 0.00% winbindd
1199 0 root 1 20 0 38040K 22688K select 2 0:01 0.00% winbindd
1213 0 root 8 20 0 31452K 11000K select 0 0:31 0.00% rrdcached
1142 0 root 1 20 0 31020K 17320K select 3 0:05 0.03% nmbd
1223 0 www 1 20 0 30916K 9876K kqread 3 0:00 0.02% nginx
1222 0 root 1 52 0 28868K 7944K pause 3 0:00 0.00% nginx
1085 0 root 1 20 0 19248K 11360K select 0 0:05 0.01% snmpd
908 0 root 2 20 0 18712K 9060K kqread 2 0:00 0.00% syslog-ng
82 0 root 1 20 0 15936K 11548K piperd 2 0:00 0.00% python3.7
424 0 root 1 52 0 15936K 11544K piperd 2 0:00 0.00% python3.7
423 0 root 1 52 0 15936K 11544K piperd 1 0:00 0.00% python3.7
420 0 root 1 52 0 15936K 11544K piperd 3 0:00 0.00% python3.7

Please advice
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,740
Hmm ... looks like a perfectly healthy system to me. Lots of inactive and free memory, no swap. What precisely do you mean by "Nextcloud cannot be accessed"? Is there a specific error message?

Anyway you should probably start a ne thread. This one is about the scripted installation, not general performance problems. Could a mod be so kind, please?
 

InGenetic

Contributor
Joined
Dec 18, 2013
Messages
183
Hmm ... looks like a perfectly healthy system to me. Lots of inactive and free memory, no swap. What precisely do you mean by "Nextcloud cannot be accessed"? Is there a specific error message?

Anyway you should probably start a ne thread. This one is about the scripted installation, not general performance problems. Could a mod be so kind, please?

if i watch carefully , everytime the free mem only 0.2 GB left , my nextcloud url can not be accessible , in the browser just white blank and the notice is "502 Bad Gateway" .if there's no a notice "502 Bad Gateway" , the browser just blank , my nextcloud will be back to normal after i restart the freenas machine , sometimes i just restart nextcloud app from jail , and it's back to normal, but sometimes it's doesn't work , i have to restart the freenas machine , after that my nextcloud url back to normal, everyone can access it.

is it i have to add more memory ram ?

please advice.
 

wxlsxn

Dabbler
Joined
May 19, 2017
Messages
29
Thank you very much @danb35!

I used this to create a new jail and migrated my existing Nextcloud configuration/data. It seems to work well so far, so I don't think I broke anything. Curious if you have any suggestions on how to do so (just in case I need to redo).

Lastly, does this script allow for use of a subdirectory e.g. https://domain.com/nextcloud/
I'm used to Nginx so I'll need to start looking into Caddy documentation.

Edit: No such luck with Caddy. It "seems" easy but I'm not grasping the subdirectory usage.

Thanks again!
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,457

G8One2

Patron
Joined
Jan 2, 2017
Messages
248
Not natively. I'd expect it could be done using a reverse proxy, but that's kind of outside the scope of the guide.

I had to do it "Reverse Proxy" myself, through my Pfsense router. Also, had to use the NO CERT=1 and add the " Strict-Transport-Security" line in the Caddyfile and 'overwriteprotocol' => 'https' to the php.conf file, to get it all working. Otherwise, your script is great!
 

Piereligio

Dabbler
Joined
Mar 9, 2021
Messages
13
You'd need to change the hostname in the Caddyfile and restart Caddy, which would take care of the certificates. You'd also need to change the "trusted domains" setting in Nextcloud's config, which you can do either by editing config.php directly, or using the occ command--the script demonstrates the latter near the end.

I tried doing this editing the Caddyfile and restarting caddy, but it seems to redirect me always to the previous hostname (failing connection to the console because of that). Maybe there's something more to do?

EDIT: editing config.php file was necessary too, I wasn't thinking of that. I'll do another edit for reporting if now it works.
EDIT2: yes now it works perfectly. Was fault of my config.php, which I had to update with the new hostname.
 
Last edited:

InGenetic

Contributor
Joined
Dec 18, 2013
Messages
183
Hi Mr.Patrick and mr. danb35 ,
really thanks for your advice ,
i' ll report later , because there's a small problem here, one of my new hdd 4TB was defect, i have to RMA the HDD .

Regards,
Hi mr Patrick and mr.danb35 ,

i'm so sorry , so far I was wrong about the hard drive that i used .
it turns out that so far I have 2 hdd on my freenas for nextcloud, i'm using 2 pcs HDD 500GB (set mirror) .
and now i want to replace that 2 hdd 500gb to new 2 hdd 6 TB .

can i do that using or via GUI not from command line ? to replacing both 500GB hdd to 6 TB hdd ?

please more advice.
 

Linge

Dabbler
Joined
Feb 27, 2021
Messages
14
Hi,
I am stuck right at the beginig of the installation. I can't run the "script nextcloud.log ./nextcloud-jail.sh" command cause there is no such file or directory. See the attachment of the screenshot from filezilla to see the files, as I don't know if there are all here as expected or if there is an issue with the github cloning?

Thanks a lot in advance.
 

Attachments

  • shot.png
    shot.png
    29.8 KB · Views: 175

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,740
You need to use ssh to login to your FreeNAS and use the console. What precisely is the command you entered? Please copy and paste the command and the resulting error message. Filezilla is completely useless here.
 

G8One2

Patron
Joined
Jan 2, 2017
Messages
248
Use PuTTy not FileZilla
 

Linge

Dabbler
Joined
Feb 27, 2021
Messages
14
Thanks for your answer.
I am sorry I didn't explain it very well.
I SSH into my NAS and cd to my dataset where I want to install my nextcloud jail. Then I typed "git clone https://github.com/danb35/freenas-iocage-nextcloud" and got the folowing files and folder (as you can see with Filezilla) but the script (nextcloud-jail.sh) was missing. Maybe I am doing something wrong?
 

G8One2

Patron
Joined
Jan 2, 2017
Messages
248
If you open the README file, it tells you that you need to create a nextcloud-config file. That file has to be created first, before you run the script
 
Top