Problems installing a snap+nginx setup

Nextcloud version: 25.0.2
Operating system and version: Ubuntu 22.0.4
Apache or nginx version: nginx 1.18.0
PHP version : non installed on machine yet, but I assume the Snap version is the more relevant question

The issue you are facing:
Trying to set up Nextcloud using Snap following this tutorial: https://nicemicro.com/tutorials/debian-snap-nextcloud.html

Running into problems though. These aren’t exactly nextcloud specific problems but I’m using this space to troubleshoot my way through the problem and if someone can help then that’s good. Basically a rubber ducky for myself. Maybe it will help someone else in the future.

Here is my console:

aslan@lovelace:~$ sudo ufw allow "Nginx Full"
Rules updated
Rules updated (v6)
aslan@lovelace:~$ ufw status
ERROR: You need to be root to run this script
aslan@lovelace:~$ sudo !!
sudo ufw status
Status: inactive
aslan@lovelace:~$ nano /etc/nginx/sites-available/nextcloud
aslan@lovelace:~$ sudo !!
sudo nano /etc/nginx/sites-available/nextcloud
aslan@lovelace:~$ sudo ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/
aslan@lovelace:~$ sudo nginx -t
nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/nextcloud:15
nginx: configuration file /etc/nginx/nginx.conf test failed
aslan@lovelace:~$ sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.

I went back and looked at where it stopped working with the UFW stuff. This is a new install of Ubuntu so there was no UFW running so I just started it up and ran the commands and I got to this point before I started getting unexpected returns in the console:

aslan@lovelace:~$ sudo nginx -t
nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/nextcloud:15
nginx: configuration file /etc/nginx/nginx.conf test failed

I thought Snap was supposed to take care of all the SSL stuff for you?

Any clue what this issue is?

I googled it and I see a stack overflow here: nginx - no "ssl_certificate" is defined for the "listen ... ssl" directive - Stack Overflow

The issue they outline is that the nginx config is missing the ssl crt file location… but again isn’t Snap supposed to handle this for me?

I guess maybe it is the ssl for the nginx then? But when I try to proceed with the rest of the tutorial to set that up, I can’t!

aslan@lovelace:~$ sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.

Hello,

Snap comes bundled with all the dependencies needed for nextcloud run. That includes Apache 2 as webserver.

If you are putting nginx ahead then I guess it needs to act like a reverse proxy and there you have to terminate SSL at Nginx level and forward the connection from there onto your snap nextcloud port.

But snap nextcloud doesn’t need anything else ahead of it to run. Ubuntu clean installation and just snap nextcloud is good enough for it to function.

By default snap nextcloud runs on 80/443. So you can’t have both nginx and snap nextcloud trying to listen on same. If you really have to have nginx ahead of it, then you need to change the snap nextcloud ports to something else.

Thanks.

If you really have to have nginx ahead of it, then you need to change the snap nextcloud ports to something else.

Right, I did that as per the instructions in the tutorial I linked.

Tried to take another crack at it, just following the commands even when their outputs diverged from the expected outputs from the tutorial. Got this when trying to set up the certbot:

┌─      ~                                                 
└─➤ sudo certbot --nginx -d cloud.aslanfrench.work
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/nextcloud:15
nginx: configuration file /etc/nginx/nginx.conf test failed

The nginx plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/nextcloud:15\nnginx: configuration file /etc/nginx/nginx.conf test failed\n')

What am I missing here? These instructions in the tutorial do not seem hard but when they don’t work I have no real understanding of why or how to troubleshoot the problem. Is the tutorial just broken?

The first sign of divergence is when I start getting the nginx reverse proxy set up and running the test command runs afoul of the nginx test command:

┌─      ~                                                 
└─➤ sudo nginx -t
nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/nextcloud:15
nginx: configuration file /etc/nginx/nginx.conf test failed

Is this just a missing step in the tutorial? How am I supposed to define the ssl cert location before even installing and running the certbot stuff etc?

Hello,

There is a GUI based project, NginX Proxy Manager. Which runs via Docker.

I have that infront of Snap Nextcloud working fine. It saves me from manual configuration of nginx !!

You may give that a try if you wish.

https://nginxproxymanager.com/

You can always contact the author of a certain tutorial in case that given tutorial isn’t producing the result as it is describing!

Thanks.

1 Like

Thank you! I will check the nginx proxy manager, sounds cool :slight_smile:

I also tried to contact the author but unfortunately their only contact info on their website is for the Fiver account. Looking over things I’m pretty sure their tutorial is just defective. I’m going to reinstall Ubuntu from scratch and try again but without the proxy server. I don’t need a proxy server for now, since I’m just running Nextcloud. I was hoping to better understand Nginx stuff from the process (versus just running an ansible playbook like I did previously) but I think for now I just need my server back up and running.