Nextcloud, nginx and self-signed certs

Hi, i’m having some trouble trying to run nextcloud (nginx) over self signed certs. I used to have this configuration on ubuntu 20 without problems. Now i’m trying to do the sane on dietpi. I created a certificate for the IP of my rasp4 following this guide How To Create a Self-Signed SSL Certificate for Nginx on Debian 10 | DigitalOcean

Now i should add the server block in the nextcloud conf but i don’t know the right passage to do that. I just need to nave nextcloud on https for intranet connection so i can use the smartphone app.

Thank you

Should be similar to what you had running on Ubuntu.

Using Nginx, Certbot will add everything into /etc/nginx/sites-available/default

Certbot will leave you with following

# /etc/nginx/sites-available/default
server {

        root /var/www;
        index index.php index.html index.htm index.nginx-debian.html;

        server_name my.domain.com;

        include /etc/nginx/sites-dietpi/*.conf;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php(?:$|/) {
                include snippets/fastcgi-php.conf;
                fastcgi_pass php;
        }

    listen [::]:443 ssl http2 ipv6only=on; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/my.domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/my.domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = my.domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80 default_server;
        listen [::]:80 default_server;

        server_name my.domain.com;
    return 404; # managed by Certbot

I didn’t use certbot, i’m not sure i can with self-signed certs created with openssl. Following that guide i modified /etc/nginx/sites-available/default like this

# /etc/nginx/sites-available/default
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    include snippets/self-signed.conf;
    include snippets/ssl-params.conf;

root /var/www/nextcloud;
        index index.html index.htm index.nginx-debian.html;

  server_name 192.168.xxx;

  location / {
                try_files $uri $uri/ =404;
        }
}

server {
    listen 80;
    listen [::]:80;

    server_name 192.168.xxx;

    return 301 https://$server_name$request_uri;
}

connetting to nextcloud i recive the usual trust warning from firefox about the self signed certificate, but then nginx respond with a 404

Well you modified the document root. This requires more modification.

Certbot was just an example how it is done there

So, how can i make it work?

I guess you would need to adjust configuration files with /etc/nginx/sites-dietpi to fit the your new root data directory setting.