I am trying to run Jitsi and Nextcloud on my NixOS server and am having some issues. First I put this in my configuration.nix:
security.acme = {
acceptTerms = true;
# Replace the email here!
email = "myemail@myemail.com";
};
If I just do this and then run it, there are no issues. Then I made a nextcloud.nix file and put in the following code which I found here:
{config, pkgs, ...}:
{
services.nginx = {
enable = true;
# Use recommended settings
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
# Only allow PFS-enabled ciphers with AES256
sslCiphers = "AES256+EECDH:AES256+EDH:!aNULL";
# Setup Nextcloud virtual host to listen on ports
virtualHosts = {
"nextcloud.example.com" = {
## Force HTTP redirect to HTTPS
forceSSL = true;
## LetsEncrypt
enableACME = true;
};
};
};
services.nextcloud = {
enable = true;
hostName = "nextcloud.example.com";
# Enable built-in virtual host management
# Takes care of somewhat complicated setup
# See here: https://github.com/NixOS/nixpkgs/blob/dab87a5bac0459886d1ab68fa52f71bcc42c396a/nixos/modules/services/web-apps/nextcloud.nix#L529
nginx.enable = true;
# Use HTTPS for links
https = true;
# Auto-update Nextcloud Apps
autoUpdateApps.enable = true;
# Set what time makes sense for you
autoUpdateApps.startAt = "05:00:00";
config = {
# Further forces Nextcloud to use HTTPS
overwriteProtocol = "https";
# Nextcloud PostegreSQL database configuration, recommended over using SQLite
dbtype = "pgsql";
dbuser = "nextcloud";
dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
dbname = "nextcloud";
dbpassFile = "/var/nextcloud-db-pass";
adminpassFile = "/var/nextcloud-admin-pass";
adminuser = "admin";
};
};
services.postgresql = {
enable = true;
# Ensure the database, user, and permissions always exist
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{ name = "nextcloud";
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
}
];
};
systemd.services."nextcloud-setup" = {
requires = ["postgresql.service"];
after = ["postgresql.service"];
};
}
And then imported nextcloud.nix in my configuration.nix.
The only things I changed were the virtual hosts and the hostname to “nc.mywebsite.com” and I removed services.nextcloud.nginx.enable=true
which was apparently deprecated.
Then on my DNS provider, I added a Type A DNS record named “nc” with the content being my server’s external IP address. I also opened up port 80. As far as I know, this should be all the things I need to change outside of NixOS.
I then created and filled /var/nextcloud-db-pass
and /var/nextcloud-admin-pass
and changed the file permissions to nextcloud:nextcloud
.
Then after running sudo nixos-rebuild swtich
, I got the following error:
the following new units were started: acme-nc.mywebsite.dev.timer, session-1698.scope
warning: the following units failed: acme-nc.mywebsite.dev.service
â—Ź acme-nc.mywebsite.dev.service - Renew ACME certificate for nc.mywebsite.dev
Loaded: loaded (/nix/store/gwrn0lqjzlsjdgihgc8krj7z389wn5b0-unit-acme-nc.mywebsite.dev.service/acme-nc.mywebsite.dev.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2021-06-13 16:11:50 EDT; 355ms ago
TriggeredBy: â—Ź acme-nc.mywebsite.dev.timer
Process: 1477695 ExecStart=/nix/store/0757c2ydlkgag3w9k202dipf8dpb1zv5-unit-script-acme-nc.mywebsite.dev-start/bin/acme-nc.mywebsite.dev-start (code=exited, status=1/FAILURE)
Main PID: 1477695 (code=exited, status=1/FAILURE)
IP: 19.1K in, 8.7K out
CPU: 310ms
Jun 13 16:11:05 nixos acme-nc.mywebsite.dev-start[1477704]: 2021/06/13 16:11:05 [INFO] [nc.mywebsite.dev] acme: Trying to solve HTTP-01
Jun 13 16:11:50 nixos acme-nc.mywebsite.dev-start[1477704]: 2021/06/13 16:11:50 [INFO] Deactivating auth: https://acme-v02.api.letsencrypt.org/acme/authz-v3/13952639864
Jun 13 16:11:50 nixos acme-nc.mywebsite.dev-start[1477704]: 2021/06/13 16:11:50 [INFO] Unable to deactivate the authorization: https://acme-v02.api.letsencrypt.org/acme/authz-v3/13952639864
Jun 13 16:11:50 nixos acme-nc.mywebsite.dev-start[1477704]: 2021/06/13 16:11:50 Could not obtain certificates:
Jun 13 16:11:50 nixos acme-nc.mywebsite.dev-start[1477704]: error: one or more domains had a problem:
Jun 13 16:11:50 nixos acme-nc.mywebsite.dev-start[1477704]: [nc.mywebsite.dev] acme: error: 403 :: urn:ietf:params:acme:error:unauthorized :: Invalid response from http://nc.mywebsite.dev/.well-known/acme-challenge/92i_mHWVNCGJtftMKW7GT9Z54FWA0IVc24dtSuukuvU [2606:4700:3036::ac43:a114]: "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en-US\"> <![endif]-->\n<!--[if IE 7]> <html class=\"no-js "...
Jun 13 16:11:50 nixos systemd[1]: acme-nc.mywebsite.dev.service: Main process exited, code=exited, status=1/FAILURE
Jun 13 16:11:50 nixos systemd[1]: acme-nc.mywebsite.dev.service: Failed with result 'exit-code'.
Jun 13 16:11:50 nixos systemd[1]: Failed to start Renew ACME certificate for nc.mywebsite.dev.
Jun 13 16:11:50 nixos systemd[1]: acme-nc.mywebsite.dev.service: Consumed 310ms CPU time, received 19.0K IP traffic, sent 8.7K IP traffic.
Hint: Some lines were ellipsized, use -l to show in full.
warning: error(s) occurred while switching to the new configuration
I then tried the same thing with Jitsi meet, finding the configuration here: NixOS - NixOS 21.05 manual. And had nearly the exact same issue.
What can I do here? Is there something I am missing or doing wrong?
Thank you in advance.