aboutsummaryrefslogblamecommitdiff
path: root/modules/private/websites/denise/evariste.nix
blob: 42f9b2e33c8dc8c65f7fa5c6186672330da6fc6c (plain) (tree)
1
2
3
4
5
6
7
8
9
                           
   




                                                   
    
                                                                                                             







                                                                
                                                

                         

                                                                                                       

           


                                                
                  

                                     
 


                                         
 

                                                                                                       
        
                              
      

                                                                      
                          
                                            






                                               
                                                                                                            











                                                            


                                                 
                  

                                     
 


                                         
 

                                                                                                         
        
                              
      

                                                                       







                                                
                                                                                                             












                                                            
{ lib, config, pkgs, ... }:
let
  cfg = config.myServices.websites.denise.evariste;
  nsiVarDir = "/var/lib/ftp/denise/nsievariste";
  stmgVarDir = "/var/lib/ftp/denise/stmgevariste";
  apacheUser = config.services.httpd.Prod.user;
  apacheGroup = config.services.httpd.Prod.group;
in {
  options.myServices.websites.denise.evariste.enable = lib.mkEnableOption "enable NSI/STMG Evariste website";

  config = lib.mkIf cfg.enable {
    services.webstats.sites = [
      { name = "nsievariste.immae.eu"; }
      { name = "stmgevariste.immae.eu"; }
    ];

    services.websites.env.production.modules = [ "proxy_fcgi" ];
    system.activationScripts.denise_evariste = {
      deps = [ "httpd" ];
      text = ''
        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/denise_nsievariste
        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/denise_stmgevariste
        '';
    };
    services.phpfpm.pools.denise_nsievariste = {
      user = apacheUser;
      group = apacheGroup;
      settings = {
        "listen.owner" = apacheUser;
        "listen.group" = apacheGroup;

        "pm" = "ondemand";
        "pm.max_children" = "5";
        "pm.process_idle_timeout" = "60";

        "php_admin_value[open_basedir]" = "/var/lib/php/sessions/denise_nsievariste:${nsiVarDir}:/tmp";
        "php_admin_value[session.save_path]" = "/var/lib/php/sessions/denise_nsievariste";
      };
      phpPackage = pkgs.php72;
    };
    services.websites.env.production.vhostConfs.denise_nsievariste = {
      certName     = "denise_evariste";
      addToCerts   = true;
      certMainHost = "nsievariste.immae.eu";
      hosts        = ["nsievariste.immae.eu" ];
      root         = nsiVarDir;
      extraConfig  = [
        ''
        Use Stats nsievariste.immae.eu

        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${config.services.phpfpm.pools.denise_nsievariste.socket}|fcgi://localhost"
        </FilesMatch>

        <Directory ${nsiVarDir}>
          DirectoryIndex index.php index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None
          Require all granted
        </Directory>
          ''
      ];
    };

    services.phpfpm.pools.denise_stmgevariste = {
      user = apacheUser;
      group = apacheGroup;
      settings = {
        "listen.owner" = apacheUser;
        "listen.group" = apacheGroup;

        "pm" = "ondemand";
        "pm.max_children" = "5";
        "pm.process_idle_timeout" = "60";

        "php_admin_value[open_basedir]" = "/var/lib/php/sessions/denise_stmgevariste:${stmgVarDir}:/tmp";
        "php_admin_value[session.save_path]" = "/var/lib/php/sessions/denise_stmgevariste";
      };
      phpPackage = pkgs.php72;
    };
    services.websites.env.production.vhostConfs.denise_stmgevariste = {
      certName     = "denise_evariste";
      addToCerts   = true;
      hosts        = ["stmgevariste.immae.eu" ];
      root         = stmgVarDir;
      extraConfig  = [
        ''
        Use Stats stmgevariste.immae.eu

        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${config.services.phpfpm.pools.denise_stmgevariste.socket}|fcgi://localhost"
        </FilesMatch>

        <Directory ${stmgVarDir}>
          DirectoryIndex index.php index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None
          Require all granted
        </Directory>
          ''
      ];
    };
  };
}