Fork of Nextcloud installation script using nginx

lbartosek

Dabbler
Joined
Dec 12, 2018
Messages
13
First of all, I'd like to give a credit to danb35 for pointing me to the right direction and re-directing me to your script.

@NasKar
Hi, I have successfully installed Nextcloud using your script today. Well done and thank you!
I was wondering, why the LE cert didn't work out of the box but I cannot give you any error logs, because, I didn't spend much time investigating/troubleshooting. I've successfully setup my already issued Comodo cert as that was my intention anyway.

I'd like to ask you one thing. I didn't find the answer in your documentation, maybe I just missed something so I better ask you. How do I install Nextcloud in the webroot instead of subdir by using your script? Because now... the Nexcloud has been installed in the subdir and I have to access it via this URL https://mydomain.com/nexcloud instead of just https://mydomain.com. I didn't find a way of setting up the installation config file otherwise in order to Install Nexcloud to webroot instead of subdir, you know.

Code:
JAIL_IP="10.0.0.100" #ip address of iocage jail
DEFAULT_GW_IP="10.0.0.238"
INTERFACE="re2"
VNET="off"
POOL_PATH="/mnt/nextcloud-pool" #your pool
JAIL_NAME="nextcloud" #name of iocage jail to be created
TIME_ZONE="Europe/Prague" # See http://php.net/manual/en/timezones.php
HOST_NAME="mydomian.com"
STANDALONE_CERT=1
DNS_CERT=0
TEST_CERT="--staging"
TYPE_CERT="--webroot"
C_NAME="CZ"
ST_NAME="Prague"
L_NAME="Prague"
O_NAME="FreeNAS"
OU_NAME="FreeNAS_IT"
EMAIL_NAME="lbartosek@mydomain.com"
NO_SSL=""


TYPE_CERT="--webroot" Probably this is the reason why the LE cert didn't work. I'll test that again later to see what is wrong.

Thank you very much once again.
 

lbartosek

Dabbler
Joined
Dec 12, 2018
Messages
13
Alright, I figured the issue with LE SSL cert by setting up the config file with these parameters below.

TEST_CERT=""
TYPE_CERT=""

The LE cert is being issued correctly and I don't get Issued by : Fake LE Intermediate X1
This CA Root certificate is not trusted because it is not in the Trusted Root Certification Authorities store.

Now, I only need to know, how to install Nextcloud in to the webroot instead of subdir by using your script. Can you please help me with that?

Thank you
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
TYPE_CERT="--webroot" Probably this is the reason why the LE cert didn't work. I'll test that again later to see what is wrong.
I beleive that is how the certificate is generated. With webroot you don't have to stop the server to renew the certificate. It has nothing to do with Nextcloud being accessed in a subdirectory. I'm no expert on this topic but I believe you need a reverse proxy to access Nextcloud not in a subdirectory. Glad the script works for you. @danb35 might be able to give you a better answer he has an extraordinary command of all these options.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I'm no expert on this topic but I believe you need a reverse proxy to access Nextcloud not in a subdirectory.
That shouldn't be needed. I don't know how you'd do it with nginx, but with Apache you just set the document root in the Nextcloud virtual host to point to the Nextcloud installation.
 

lbartosek

Dabbler
Joined
Dec 12, 2018
Messages
13
That shouldn't be needed. I don't know how you'd do it with nginx, but with Apache you just set the document root in the Nextcloud virtual host to point to the Nextcloud installation.

Hi,
It's been a long time I didn't play with my nextcloud config and so on. I was going to thank you for all your answers and insights. It was very useful and helpful for me. Anyway, I had a problem accessing my nextcloud from internal network recently but I have finally figured it out. All of the sudden, it stopped working and I didn't know why. I fixed it for now by setting up the jail IP address in DMZ section on my router but I still don't get it, cause I could access it from the internet anyway. I used the DMZ for my desktop PC that I usually access it remotely,however, I had to switch my desktop IP address to the jail IP address and it started working. Never mind, I am glad it's working again.

I'd like to now play with the nextcloud config and test out some plugins, however, I haven't figured out how your Backup & restore script works :(
I was looking for these two files (NextcloudBR.sh and NextcloudBR-config) in whole jail but I couldn't find it.

In your script description... it says that these two files are automatically copied to the jail /usr directory but I only found it in the git cloned folder.
NextcloudBR.sh and NextcloudBR-config are automatically copied to the jails /usr directory.

Do you happen to have or know any detailed guide on how to set it up along with cron as I'd like to automate backups on regular basis, please?

Thank you
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
it says that these two files are automatically copied to the jail /user directory
Not /user (which doesn't exist), but /usr. But even then, it looks like there's a bug in the script--the part that is supposed to copy those files (lines 313-319) copies them from /git on your FreeNAS box, which isn't likely to exist for most people. This part is all @NasKar's work, so he'll need to fix that.
 

lbartosek

Dabbler
Joined
Dec 12, 2018
Messages
13
Not /user (which doesn't exist), but /usr. But even then, it looks like there's a bug in the script--the part that is supposed to copy those files (lines 313-319) copies them from /git on your FreeNAS box, which isn't likely to exist for most people. This part is all @NasKar's work, so he'll need to fix that.

My bad. I just edited the line above the quote and corrected the folder name. I meant the usr directory anyway.

I was wondering that these files are nowhere to be found. Is there a way to manually set it up in such case? Because, if NasKar fixes it, that'll be applied for fresh installation only, right? I'd love to back up my Nexcloud jail and database as soon as I can in order to start customizing it and test out some plugins. I believe it can be used for migration to different servers somehow as well. I've been using snapshots but perhaps I am not doing it correctly. I cannot recall what happened exactly when I did rollback but I'll definitely try it out again.

Thank you
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Is there a way to manually set it up in such case?
Sure--a bunch of ways it could be done. I'd probably enter the jail with iocage console nextcloud, then fetch -o /tmp https://raw.githubusercontent.com/NasKar2/freenas-iocage-nextcloud/master/NextcloudBR.sh https://raw.githubusercontent.com/NasKar2/freenas-iocage-nextcloud/master/NextcloudBR-config, then chmod +x /usr/NextcloudBR.sh. You'd need to edit NextcloudBR-config to have the database user's password as well.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
Sure--a bunch of ways it could be done. I'd probably enter the jail with iocage console nextcloud, then fetch -o /tmp https://raw.githubusercontent.com/NasKar2/freenas-iocage-nextcloud/master/NextcloudBR.sh https://raw.githubusercontent.com/NasKar2/freenas-iocage-nextcloud/master/NextcloudBR-config, then chmod +x /usr/NextcloudBR.sh. You'd need to edit NextcloudBR-config to have the database user's password as well.
Thats exactly the way to do it. I've update the script to move the NextcloudBR.sh and NexcloudBR-config to the configs/ folder so it would be more generic. When you run the script from scratch it copies the nextcloud password into the Nextcloud-config and restricts access to it with chmod 600. Thanks @danb35 for your suggestions.
 
Top