mirror of
https://github.com/archtechx/nix.git
synced 2025-12-12 03:24:02 +00:00
Multi-domain support
This commit is contained in:
parent
34a84d3a11
commit
04812f9a98
2 changed files with 13 additions and 7 deletions
11
README.md
11
README.md
|
|
@ -72,10 +72,10 @@ Import the module in your system flake and invoke it with these parameters:
|
|||
```nix
|
||||
(laravelSite {
|
||||
name = "mysite";
|
||||
domain = "mysite.com";
|
||||
domains = [ "mysite.com" ];
|
||||
phpPackage = pkgs.php84;
|
||||
|
||||
ssl = true; # optional, defaults to false
|
||||
ssl = true; # optional, defaults to false, affects *ALL* domains
|
||||
extraNginxConfig = "nginx configuration string"; # optional
|
||||
sshKeys = [ "array" "of" "public" "ssh" "keys" ]; # optional
|
||||
extraPackages = [ pkgs.nodejs_24 ]; # optional
|
||||
|
|
@ -111,7 +111,7 @@ to false).
|
|||
|
||||
Also, if you're using `ssl` you should put this line into your system config:
|
||||
```nix
|
||||
security.acme.email = "your@email.com";
|
||||
security.acme.defaults.email = "your@email.com";
|
||||
```
|
||||
|
||||
A full system config can look something like this (excluding any additional configuration
|
||||
|
|
@ -134,7 +134,10 @@ you may want to make):
|
|||
inherit system;
|
||||
|
||||
modules = [
|
||||
{ nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; }
|
||||
{
|
||||
nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
|
||||
security.acme.defaults.email = "your@email.com";
|
||||
}
|
||||
./configuration.nix
|
||||
|
||||
# your (laravelSite { ... }) calls here
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ name, domain, ssl ? false, extraNginxConfig ? null, sshKeys ? null, phpPackage, extraPackages ? [], queue ? false, queueArgs ? "", generateSshKey ? true, poolSettings ? {
|
||||
{ name, phpPackage, domains ? [], ssl ? false, extraNginxConfig ? null, sshKeys ? null, extraPackages ? [], queue ? false, queueArgs ? "", generateSshKey ? true, poolSettings ? {
|
||||
"pm" = "dynamic";
|
||||
"pm.max_children" = 8;
|
||||
"pm.start_servers" = 2;
|
||||
|
|
@ -28,6 +28,7 @@ in {
|
|||
environment.etc."laravel-${name}-bashrc".text = ''
|
||||
# Laravel site welcome message
|
||||
echo "Welcome to ${name} Laravel site!"
|
||||
echo "Domains: ${lib.concatStringsSep ", " domains}"
|
||||
echo "User home: /home/${mkUsername name}"
|
||||
echo "Site: /srv/${name}"
|
||||
echo "Restart php-fpm: sudo systemctl reload phpfpm-${name}"
|
||||
|
|
@ -101,7 +102,9 @@ in {
|
|||
};
|
||||
|
||||
# Nginx virtual host configuration
|
||||
services.nginx.virtualHosts.${domain} = {
|
||||
# Note: these assignments within modules do NOT override the existing value that
|
||||
# virtualHosts may have. Instead, all vhost configurations get merged into one.
|
||||
services.nginx.virtualHosts = lib.genAttrs domains (domain: {
|
||||
enableACME = ssl;
|
||||
forceSSL = ssl;
|
||||
root = "/srv/${name}/public";
|
||||
|
|
@ -141,7 +144,7 @@ in {
|
|||
deny all;
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
# PHP-FPM pool configuration
|
||||
services.phpfpm.pools.${name} = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue