set upload limits

This commit is contained in:
Yisroel Baum 2026-07-03 15:04:07 +03:00
parent ec956c1ca8
commit 757be61f59
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
6 changed files with 34 additions and 11 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
/.reference/ /.reference/
/backend/.phpunit.cache/ /backend/.phpunit.cache/
/.postgres/ /.postgres/
/result
/result-*

View file

@ -18,8 +18,12 @@
system: system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
devPhp = pkgs.php; devPhp = pkgs.php.buildEnv {
packages = import ./nix/packages { inherit pkgs; }; extraConfig = uploadLimits.phpOptions;
};
packages = import ./nix/packages {
inherit pkgs uploadLimits;
};
in in
{ {
inherit packages; inherit packages;

View file

@ -13,6 +13,7 @@ let
appDir = "${backendPackage}/share/php/rabbi-gerzi-backend"; appDir = "${backendPackage}/share/php/rabbi-gerzi-backend";
phpPackage = backendPackage.passthru.php; phpPackage = backendPackage.passthru.php;
poolName = "rabbi-gerzi"; poolName = "rabbi-gerzi";
uploadLimits = import ./upload-limits.nix;
storagePath = "${cfg.stateDir}/storage"; storagePath = "${cfg.stateDir}/storage";
cachePath = "${cfg.cacheDir}/bootstrap-cache"; cachePath = "${cfg.cacheDir}/bootstrap-cache";
setupService = "rabbi-gerzi-setup"; setupService = "rabbi-gerzi-setup";
@ -239,6 +240,7 @@ in
services.phpfpm.pools.${poolName} = { services.phpfpm.pools.${poolName} = {
inherit (cfg) user group; inherit (cfg) user group;
inherit phpPackage; inherit phpPackage;
phpOptions = uploadLimits.phpOptions;
settings = { settings = {
"catch_workers_output" = true; "catch_workers_output" = true;
"clear_env" = "no"; "clear_env" = "no";
@ -316,6 +318,9 @@ in
cfg.backend.nginx cfg.backend.nginx
{ {
root = "${appDir}/public"; root = "${appDir}/public";
extraConfig = ''
client_max_body_size ${uploadLimits.nginxClientMaxBodySize};
'';
locations = { locations = {
"/" = { "/" = {
index = "index.php"; index = "index.php";

View file

@ -2,16 +2,19 @@
lib, lib,
makeWrapper, makeWrapper,
php, php,
uploadLimits ? import ../upload-limits.nix,
}: }:
let let
phpPackage = php.withExtensions ( phpPackage = php.buildEnv {
extensions =
{ enabled, all }: { enabled, all }:
enabled enabled
++ [ ++ [
all.pdo_pgsql all.pdo_pgsql
] ];
); extraConfig = uploadLimits.phpOptions;
};
in in
phpPackage.buildComposerProject2 (finalAttrs: { phpPackage.buildComposerProject2 (finalAttrs: {
pname = "rabbi-gerzi-backend"; pname = "rabbi-gerzi-backend";

View file

@ -1,7 +1,12 @@
{ pkgs }: {
pkgs,
uploadLimits ? import ../upload-limits.nix,
}:
rec { rec {
backend = pkgs.callPackage ./backend.nix { }; backend = pkgs.callPackage ./backend.nix {
inherit uploadLimits;
};
frontend = pkgs.callPackage ./frontend.nix { }; frontend = pkgs.callPackage ./frontend.nix { };
default = frontend; default = frontend;
} }

View file

@ -1,4 +1,8 @@
{ {
nginxClientMaxBodySize = "6m"; nginxClientMaxBodySize = "6m";
phpUploadLimit = "6M"; phpUploadLimit = "6M";
phpOptions = ''
upload_max_filesize = 6M
post_max_size = 6M
'';
} }