2022-09-14 08:47:49 +02:00
|
|
|
{ stdenv
|
|
|
|
, pkgs
|
|
|
|
}:
|
|
|
|
{ serviceName
|
|
|
|
, serviceSocket
|
2022-09-29 08:34:03 +02:00
|
|
|
, phpFastcgi ? false
|
|
|
|
, phpDocroot ? null
|
|
|
|
, phpIndex ? "index.php"
|
2022-09-14 08:47:49 +02:00
|
|
|
}:
|
|
|
|
|
2022-09-29 08:34:03 +02:00
|
|
|
let
|
|
|
|
backend =
|
|
|
|
if !phpFastcgi
|
|
|
|
then ''
|
|
|
|
backend ${serviceName}
|
|
|
|
mode http
|
|
|
|
option forwardfor
|
|
|
|
server ${serviceName}1 ${serviceSocket}
|
|
|
|
'' else ''
|
|
|
|
backend ${serviceName}
|
|
|
|
mode http
|
|
|
|
option forwardfor
|
|
|
|
use-fcgi-app ${serviceName}-php-fpm
|
|
|
|
server ${serviceName}1 ${serviceSocket} proto fcgi
|
|
|
|
|
|
|
|
fcgi-app ${serviceName}-php-fpm
|
|
|
|
log-stderr global
|
|
|
|
docroot ${phpDocroot}
|
|
|
|
index ${phpIndex}
|
|
|
|
path-info ^(/.+\.php)(/.*)?$
|
|
|
|
'';
|
|
|
|
in
|
2022-09-14 08:47:49 +02:00
|
|
|
{
|
|
|
|
acl = ''
|
|
|
|
acl acl_${serviceName} hdr_beg(host) ${serviceName}.
|
|
|
|
use_backend ${serviceName} if acl_${serviceName}
|
|
|
|
'';
|
|
|
|
|
2022-09-29 08:34:03 +02:00
|
|
|
inherit backend;
|
2022-09-14 08:47:49 +02:00
|
|
|
}
|