nextcloud: Use a hardened systemd unit instead of a container
This commit is contained in:
parent
d5157e612f
commit
6fe61dd9b6
|
@ -9,6 +9,7 @@
|
||||||
./services/nextcloud.nix
|
./services/nextcloud.nix
|
||||||
./services/webserver.nix
|
./services/webserver.nix
|
||||||
./services/starbound.nix
|
./services/starbound.nix
|
||||||
|
./services/postgres.nix
|
||||||
./ids.nix
|
./ids.nix
|
||||||
./sops.nix
|
./sops.nix
|
||||||
];
|
];
|
||||||
|
@ -81,7 +82,10 @@
|
||||||
in {
|
in {
|
||||||
"${domain}" = proxyPassToPort 3002 {serverAliases = ["www.${domain}"];};
|
"${domain}" = proxyPassToPort 3002 {serverAliases = ["www.${domain}"];};
|
||||||
"gitea.${domain}" = proxyPassToPort 3000 {};
|
"gitea.${domain}" = proxyPassToPort 3000 {};
|
||||||
"nextcloud.${domain}" = proxyPassToPort 3001 {};
|
"nextcloud.${domain}" = {
|
||||||
|
forceSSL = true;
|
||||||
|
enableACME = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,53 +1,35 @@
|
||||||
{config, ...}: {
|
{
|
||||||
virtualisation.pods.nextcloud = {
|
pkgs,
|
||||||
hostname = "nextcloud.tlater.net";
|
config,
|
||||||
publish = ["3001:80"];
|
...
|
||||||
network = "slirp4netns";
|
}: let
|
||||||
|
inherit (pkgs) fetchNextcloudApp;
|
||||||
|
nextcloud = pkgs.nextcloud23;
|
||||||
|
in {
|
||||||
|
services.nextcloud = {
|
||||||
|
package = nextcloud;
|
||||||
|
enable = true;
|
||||||
|
hostName = "nextcloud.${config.services.nginx.domain}";
|
||||||
|
maxUploadSize = "2G";
|
||||||
|
https = true;
|
||||||
|
|
||||||
containers = {
|
config = {
|
||||||
nextcloud = {
|
overwriteProtocol = "https";
|
||||||
image = "nextcloud:fpm-alpine";
|
|
||||||
dependsOn = ["postgres"];
|
|
||||||
volumes = [
|
|
||||||
"nextcloud-root:/var/www/html"
|
|
||||||
"nextcloud-apps:/var/www/html/custom_apps"
|
|
||||||
"nextcloud-config:/var/www/html/config"
|
|
||||||
"nextcloud-data:/var/www/html/data"
|
|
||||||
];
|
|
||||||
environment = {
|
|
||||||
POSTGRES_DB = "nextcloud";
|
|
||||||
POSTGRES_USER = "nextcloud";
|
|
||||||
POSTGRES_HOST = "localhost";
|
|
||||||
OVERWRITEPROTOCOL = "https";
|
|
||||||
TRUSTED_PROXIES = "127.0.0.1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
cron = {
|
dbtype = "pgsql";
|
||||||
image = "nextcloud:fpm-alpine";
|
dbhost = "/run/postgresql";
|
||||||
entrypoint = "/cron.sh";
|
|
||||||
dependsOn = ["postgres" "nextcloud"];
|
|
||||||
extraOptions = ["--volumes-from=nextcloud-nextcloud"];
|
|
||||||
};
|
|
||||||
|
|
||||||
nginx = {
|
adminuser = "tlater";
|
||||||
image = "nginx:alpine";
|
adminpassFile = config.sops.secrets."nextcloud/tlater".path;
|
||||||
dependsOn = ["nextcloud"];
|
|
||||||
volumes = [
|
|
||||||
"nextcloud-root:/var/www/html:ro"
|
|
||||||
"${./configs/nginx-nextcloud.conf}:/etc/nginx/nginx.conf:ro"
|
|
||||||
];
|
|
||||||
extraOptions = ["--volumes-from=nextcloud-nextcloud"];
|
|
||||||
};
|
|
||||||
|
|
||||||
postgres = {
|
defaultPhoneRegion = "AT";
|
||||||
image = "postgres:alpine";
|
|
||||||
environment = {
|
|
||||||
POSTGRES_DB = "nextcloud";
|
|
||||||
POSTGRES_USER = "nextcloud";
|
|
||||||
};
|
|
||||||
volumes = ["nextcloud-postgres-14:/var/lib/postgresql/data"];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO(tlater): Add redis config. This will be much easier
|
||||||
|
# starting with 22.11, since this will add an `extraOptions` where
|
||||||
|
# the necessary redis config can go.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Ensure that this service doesn't start before postgres is ready
|
||||||
|
systemd.services.nextcloud-setup.after = ["postgresql.service"];
|
||||||
}
|
}
|
||||||
|
|
30
configuration/services/postgres.nix
Normal file
30
configuration/services/postgres.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
services.postgresql = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
# Only enable connections via the unix socket, and check with the
|
||||||
|
# OS to make sure the user matches the database name.
|
||||||
|
#
|
||||||
|
# See https://www.postgresql.org/docs/current/auth-pg-hba-conf.html
|
||||||
|
authentication = ''
|
||||||
|
local sameuser all peer
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Note: The following options with ensure.* are set-only; i.e.,
|
||||||
|
# when permissions/users/databases are removed from these lists,
|
||||||
|
# that operation needs to be performed manually on the system as
|
||||||
|
# well.
|
||||||
|
ensureUsers = [
|
||||||
|
{
|
||||||
|
name = "nextcloud";
|
||||||
|
ensurePermissions = {
|
||||||
|
"DATABASE nextcloud" = "ALL PRIVILEGES";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
ensureDatabases = [
|
||||||
|
"nextcloud"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue