Nginx self signed certificate

I’m trying to run Nextcloud on LAN where I can’t get SSL certificate from Let’s Encrypt. Therefore I use self signed certificate which were generated by:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nc-selfsigned.key -out /etc/nc-selfsigned.crt

The nginx config is following:

virtualHosts."" = {
	forceSSL = true;
	sslCertificate = "/etc/nc-selfsigned.crt";
	sslCertificateKey = "/etc/nc-selfsigned.key";
	listen = [
		{ addr = ""; port=80; }

However the nginx service crashes with this output:

nginx: [warn] "ssl_stapling" ignored, issuer certificate not found for certificate "/etc/nc-selfsigned.crt"
2021/03/24 20:26:30 [emerg] 77312#77312: open() "/run/nginx/" failed (2: No such file or directory)

Does it help to set the self signed certificate as the ssl chain file as well?

(I am on NixOS unstable and the options are called services.httpd.virtualHosts.<name>.sslServerCert, services.httpd.virtualHosts.<name>.sslServerChain and services.httpd.virtualHosts.<name>.sslServerKey here)

Or you can look for solutions that are not specific to nixos but your special nginx error message:

or maybe even better

the point about ssl_trusted_certificate.