Add: ftp config
This commit is contained in:
parent
a68fbcf432
commit
b11dd2ed72
4 changed files with 106 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
[ # Include the results of the hardware scan.
|
[ # Include the results of the hardware scan.
|
||||||
./hardware.nix
|
./hardware.nix
|
||||||
../../profiles/server-selfhosted.nix
|
../../profiles/server-selfhosted.nix
|
||||||
|
../../modules/services/ftp.nix
|
||||||
../../modules/services/forgejo.nix
|
../../modules/services/forgejo.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
59
modules/services/ftp.nix
Normal file
59
modules/services/ftp.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
{ config, pkgs, lib, ... }: {
|
||||||
|
# -------------------------------------------------
|
||||||
|
# 1️⃣ Création de l’utilisateur système dédié FTP
|
||||||
|
# -------------------------------------------------
|
||||||
|
users.users.ftpuser = {
|
||||||
|
isSystemUser = true; # pas de login shell
|
||||||
|
description = "Compte FTP dédié";
|
||||||
|
home = "/srv/ftp/ftpuser";
|
||||||
|
createHome = true;
|
||||||
|
group = "ftpuser";
|
||||||
|
shell = "/usr/sbin/nologin";
|
||||||
|
};
|
||||||
|
users.groups.ftpuser = {};
|
||||||
|
|
||||||
|
# -------------------------------------------------
|
||||||
|
# 2️⃣ Permissions du répertoire home (méthode A)
|
||||||
|
# -------------------------------------------------
|
||||||
|
system.activationScripts.setupFtp = ''
|
||||||
|
# Répertoire racine du chroot – lecture‑seule
|
||||||
|
chmod a-w /srv/ftp/ftpuser
|
||||||
|
# Sous‑répertoire où l’on peut écrire
|
||||||
|
mkdir -p /srv/ftp/ftpuser/upload
|
||||||
|
chown ftpuser:ftpuser /srv/ftp/ftpuser/upload
|
||||||
|
chmod 755 /srv/ftp/ftpuser/upload
|
||||||
|
'';
|
||||||
|
|
||||||
|
# -------------------------------------------------
|
||||||
|
# 3️⃣ Configuration du serveur vsftpd
|
||||||
|
# -------------------------------------------------
|
||||||
|
services.vsftpd = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
# Autoriser les comptes locaux (system users)
|
||||||
|
localUsers = false;
|
||||||
|
|
||||||
|
# Refuser l’accès anonyme (sécurité renforcée)
|
||||||
|
anonymousUser = false;
|
||||||
|
|
||||||
|
# Chroot chaque utilisateur local dans son $HOME
|
||||||
|
chrootlocalUser = true;
|
||||||
|
allowWriteableChroot = true ;
|
||||||
|
|
||||||
|
extraConfig = ''
|
||||||
|
pasv_min_port=40000
|
||||||
|
pasv_max_port=40004
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
# -------------------------------------------------
|
||||||
|
# 4️⃣ Ouverture des ports dans le firewall NixOS
|
||||||
|
# -------------------------------------------------
|
||||||
|
networking.firewall = {
|
||||||
|
allowedTCPPorts = [ 21 40000 40001 40002 40003 40004 ];
|
||||||
|
# Si vous utilisez FTPS implicite (port 990) :
|
||||||
|
# allowedTCPPorts = [ 21 990 40000 40001 40002 40003 40004 ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
45
modules/sites/levr.porzh.me.nix
Normal file
45
modules/sites/levr.porzh.me.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# 1️⃣ Caddy (reverse‑proxy / serveur web statique)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
services.caddy = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
# Caddy démarre en tant qu’utilisateur « caddy ».
|
||||||
|
# On lui donne accès au répertoire du blog via les ACL créées plus haut.
|
||||||
|
# (Pas besoin de config supplémentaire côté OS.)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# 2️⃣ Sites gérés par Caddy (Caddyfile intégré)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
virtualHosts = {
|
||||||
|
"levr.porzh.me" = {
|
||||||
|
# Le domaine sera automatiquement provisionné avec TLS via ACME
|
||||||
|
# (Let's Encrypt) grâce à l’option `autoHTTPS = true` (défaut).
|
||||||
|
# Aucun certificat manuel n’est requis.
|
||||||
|
|
||||||
|
# Le répertoire contenant les fichiers générés par Hugo
|
||||||
|
|
||||||
|
# (Optionnel) Rediriger HTTP → HTTPS – Caddy le fait déjà,
|
||||||
|
# mais on le rend explicite pour la clarté.
|
||||||
|
extraConfig = ''
|
||||||
|
@http {
|
||||||
|
protocol http
|
||||||
|
}
|
||||||
|
redir @http https://{host}{uri} permanent
|
||||||
|
root * /srv/blog/public
|
||||||
|
file_server
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# 3️⃣ Ouverture du firewall (ports 80 et 443)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
networking.firewall.allowedTCPPorts = [
|
||||||
|
80 # HTTP (pour la redirection ACME)
|
||||||
|
443 # HTTPS (site final)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
../modules/common/networking.nix
|
../modules/common/networking.nix
|
||||||
../modules/services/printing.nix
|
../modules/services/printing.nix
|
||||||
../modules/sites/porzh.me.nix
|
../modules/sites/porzh.me.nix
|
||||||
|
../modules/sites/levr.porzh.me.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue