Enable HTTPS on NextCloud

Hello,
I have installed ubuntu 22.04 multiple times with snap and no problem logging into the localhost via http. Here are the details on the config.

ubuntu 22.04 lts
192.168.1.50
trusted_domain has IP and domain listed
I am using cloudflare dns and ssl and have the domain IP from namecheap pointed with an A record in cloudflare.
ufw 80/443 is allowed

I am only trying to get it to force https from the local lan right now.
Every article I see either has you modifying the config.php files on a manual nextcloud install or suggest you edit the files from the snap installation, however those are read-only and you cannot modify them even if you are root.

Any suggestions on how to enable https and force the ssl from cloudflare? I had an oracle instance yesterday setup and everything worked like it should for whatever reason. Nothing was different on the installation except oracle was not on LTS version.

thanks!

I just created cert.pem files from cloudflare and uploaded to server. The nextcloud is latest and was installed via snap. When getting to the lets-encrypt portion I am assuming I can load the .pem files there?

thanks!

Hello,

You need to download all 3 .pem files from CloudFlare SSL (Your SSL Certificate, Private Key, and Key Chain.)

You may need to create a directory custom (not necessary but for installation purpose only) under /var/snap/nextcloud/current/certs/

You need to put all three .PEM files in that directory /var/snap/nextcloud/current/certs/custom/

Navigate your self via terminal to that direcoty and then run the following command, sudo nextcloud.enable-https custom -s cert.pem privkey.pem chain.pem

Refer here → Using your own SSL certs in snap · Issue #199 · nextcloud-snap/nextcloud-snap (github.com)

Thanks.

Hi NaXal,
Thanks for the info. I do not seem to be able to find the key chain on cloudflare for some reason. Once I find it I’ll copy them in that folder and issue the command.

Thanks again!

Kevin

1 Like

Update. I deleted the VM and started from scratch. This time I selected to install nextcloud on the installation as a package instead of installing after ubuntu was finished installing. Gave it a static IP in class C, added my domain as a trusted domain, and enable-https lets-encrypt. This time for whatever reason there were no errors. My domain is registered through namecheap, cloudflare controls the dns and the public IP is tied to my domain name. No clue really why it worked this time, I did nothing different in the past 4 installations LOL. The only thing I did do was delete the old MX and txt records on cloudflare which was pointing to namehost.

Thanks!

Hello,

Pardon me, but I see a major difference. Which was your initial and actual issue.

Here is your initial issue,

And here is what you did on your second fresh installation,

SSL from CloudFlare vs SSL from Let’s encrypt generated via snap

You needed to have SSL installed within Snap itself, and second time around, you did it with Let’s Encrypt !!

Thanks.

1 Like

Hi NaXal,

Wanted to clarify a few things in case it sounded confusing :smiley:

Each VM was set a static IP of 192.168.1.x and four of the VM instances I installed nextcloud via the terminal and went through the setup and lets-encrypt, however it would always come back with a failed attempt. When I decided to actually let the ubuntu server installation install nextcloud during the installation and I issued lets-encrypt it worked. That is what I could not understand because everything was the same except for the manual installation of nextcloud vs the ubuntu server installation to have it install it.

Thanks for the help !

Kevin