2018-05-10 18:53:34 +02:00
|
|
|
{ lib, config, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.site-musique;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.site-musique = {
|
|
|
|
enable = mkEnableOption "Site musique";
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
example = 54321;
|
|
|
|
description = "Local listening port";
|
|
|
|
};
|
2018-05-17 15:43:35 +02:00
|
|
|
|
|
|
|
domaine = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "example.com";
|
|
|
|
description = "Domaine à utiliser";
|
|
|
|
};
|
2018-05-10 18:53:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
services.haproxy-acme.services = {
|
2018-05-17 15:43:35 +02:00
|
|
|
${cfg.domaine} = { ip = "127.0.0.1"; port = cfg.port; auth = false; };
|
2018-05-10 18:53:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
"musique" = {
|
|
|
|
listen = [ { addr = "127.0.0.1"; port = cfg.port; } ];
|
|
|
|
locations."/" = {
|
2018-11-10 15:23:46 +01:00
|
|
|
root = "/run/python-ci/nyanloutre/site-musique";
|
2018-05-10 18:53:34 +02:00
|
|
|
index = "index.php";
|
|
|
|
extraConfig = ''
|
|
|
|
location ~* \.php$ {
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
2019-10-04 22:36:31 +02:00
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.musique.socket};
|
2018-05-10 18:53:34 +02:00
|
|
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
|
|
|
include ${pkgs.nginx}/conf/fastcgi.conf;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-10-04 22:36:31 +02:00
|
|
|
services.phpfpm.pools.musique = {
|
|
|
|
user = "nginx";
|
|
|
|
settings = {
|
|
|
|
"listen.owner" = "nginx";
|
|
|
|
"listen.group" = "nginx";
|
|
|
|
"listen.mode" = "0660";
|
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 75;
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
"pm.min_spare_servers" = 1;
|
|
|
|
"pm.max_spare_servers" = 20;
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
"php_admin_value[error_log]" = "stderr";
|
|
|
|
"php_admin_flag[log_errors]" = "on";
|
|
|
|
"catch_workers_output" = "yes";
|
|
|
|
};
|
|
|
|
};
|
2018-05-10 18:53:34 +02:00
|
|
|
};
|
|
|
|
}
|