I’ve tried to include nginx with the simple example setup from this page:
https://nixos.wiki/wiki/Nginx
But as soon as the new configuration is active, I am getting the following nginx startup error:
nginx-pre-start[13108]: nginx: [emerg] open() “/var/log/nginx/access.log” failed (13: Permission denied)
I have no idea why nginx can’t write to its default access.log location.
Does anyone have an idea how to figure out whats wrong on my system?
my nixos configuration is:
{ config, pkgs, lib, ... }:
let
app = "myApp";
domain = "${app}.mydomain.com";
dataDir = "/var/www/${domain}";
in
{
services.nginx.enable = true;
systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/log/nginx/" ];
systemd.services.nginx.serviceConfig.ProtectHome = false;
services.nginx.virtualHosts.${domain} = {
root = "${dataDir}/html";
forceSSL = false;
};
users.users.${app} = {
isSystemUser = true;
createHome = true;
home = dataDir;
group = app;
};
users.groups.${app} = {};
networking.firewall.allowedTCPPorts = [ 80 443 ];
}