Merge pull request #276496 from Izorkin/update-roundcube-nginx

nixos/roundcube: update nginx configuration

authored by Maximilian Bosch and committed by GitHub 7f91c8ef 0c7757c5

+31 -12
+31 -12
nixos/modules/services/mail/roundcube.nix
··· 102 102 apply = configuredMaxAttachmentSize: "${toString (configuredMaxAttachmentSize * 1.3)}M"; 103 103 }; 104 104 105 + configureNginx = lib.mkOption { 106 + type = lib.types.bool; 107 + default = true; 108 + description = lib.mdDoc "Configure nginx as a reverse proxy for roundcube."; 109 + }; 110 + 105 111 extraConfig = mkOption { 106 112 type = types.lines; 107 113 default = ""; ··· 142 148 ${cfg.extraConfig} 143 149 ''; 144 150 145 - services.nginx = { 151 + services.nginx = lib.mkIf cfg.configureNginx { 146 152 enable = true; 147 153 virtualHosts = { 148 154 ${cfg.hostName} = { 149 155 forceSSL = mkDefault true; 150 156 enableACME = mkDefault true; 157 + root = cfg.package; 151 158 locations."/" = { 152 - root = cfg.package; 153 159 index = "index.php"; 160 + priority = 1100; 154 161 extraConfig = '' 155 - location ~* \.php(/|$) { 156 - fastcgi_split_path_info ^(.+\.php)(/.+)$; 157 - fastcgi_pass unix:${fpm.socket}; 158 - 159 - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 160 - fastcgi_param PATH_INFO $fastcgi_path_info; 161 - 162 - include ${config.services.nginx.package}/conf/fastcgi_params; 163 - include ${pkgs.nginx}/conf/fastcgi.conf; 164 - } 162 + add_header Cache-Control 'public, max-age=604800, must-revalidate'; 163 + ''; 164 + }; 165 + locations."~ ^/(SQL|bin|config|logs|temp|vendor)/" = { 166 + priority = 3110; 167 + extraConfig = '' 168 + return 404; 169 + ''; 170 + }; 171 + locations."~ ^/(CHANGELOG.md|INSTALL|LICENSE|README.md|SECURITY.md|UPGRADING|composer.json|composer.lock)" = { 172 + priority = 3120; 173 + extraConfig = '' 174 + return 404; 175 + ''; 176 + }; 177 + locations."~* \\.php(/|$)" = { 178 + priority = 3130; 179 + extraConfig = '' 180 + fastcgi_pass unix:${fpm.socket}; 181 + fastcgi_param PATH_INFO $fastcgi_path_info; 182 + fastcgi_split_path_info ^(.+\.php)(/.+)$; 183 + include ${config.services.nginx.package}/conf/fastcgi.conf; 165 184 ''; 166 185 }; 167 186 };