feat: nextcloud subdirectory

This commit is contained in:
s-prechtl 2025-06-21 23:03:36 +02:00
parent d9e3a1aeb1
commit e61c815c7c

View file

@ -1,4 +1,8 @@
{config, pkgs, ...}: { {
config,
pkgs,
...
}: {
# This is only a temporary password and will be changed # This is only a temporary password and will be changed
environment.etc."nextcloud-admin-pass".text = "samcsamc11"; environment.etc."nextcloud-admin-pass".text = "samcsamc11";
services.nextcloud = { services.nextcloud = {
@ -6,15 +10,66 @@
hostName = "sprechtl.ddns.net"; hostName = "sprechtl.ddns.net";
https = true; https = true;
package = pkgs.nextcloud31; package = pkgs.nextcloud31;
settings = let
prot = "http"; # or https
host = "127.0.0.1";
dir = "/nextcloud";
in {
overwriteprotocol = prot;
overwritehost = host;
overwritewebroot = dir;
overwrite.cli.url = "${prot}://${host}${dir}/";
htaccess.RewriteBase = dir;
};
config = { config = {
adminpassFile = "/etc/nextcloud-admin-pass"; adminpassFile = "/etc/nextcloud-admin-pass";
dbtype = "sqlite"; dbtype = "sqlite";
}; };
}; };
services.nginx.virtualHosts.${config.services.nextcloud.hostName} = { services.nginx = {
forceSSL = true; virtualHosts.${config.services.nextcloud.hostName} = {
enableACME = true; forceSSL = true;
enableACME = true;
listen = [
{
addr = "127.0.0.1";
port = 8080; # NOT an exposed port
}
];
};
virtualHosts."localhost" = {
"/nextcloud/" = {
priority = 9999;
extraConfig = ''
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto http;
proxy_pass http://127.0.0.1:8080/; # tailing / is important!
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
'';
};
"^~ /.well-known" = {
priority = 9000;
extraConfig = ''
absolute_redirect off;
location ~ ^/\\.well-known/(?:carddav|caldav)$ {
return 301 /nextcloud/remote.php/dav;
}
location ~ ^/\\.well-known/host-meta(?:\\.json)?$ {
return 301 /nextcloud/public.php?service=host-meta-json;
}
location ~ ^/\\.well-known/(?!acme-challenge|pki-validation) {
return 301 /nextcloud/index.php$request_uri;
}
try_files $uri $uri/ =404;
'';
};
};
}; };
security.acme = { security.acme = {