From ccaeb8335e512039672a8d5659ba90eb5988575e Mon Sep 17 00:00:00 2001 From: Joby Elliott Date: Fri, 25 Oct 2024 15:27:23 -0600 Subject: [PATCH] allow per-site custom nginx config, improving permissions --- add-site.sh | 11 ++++++++--- install/000-update-install.sh | 3 +++ site-config.conf | 3 +++ update-site.sh | 15 +++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/add-site.sh b/add-site.sh index bae5eb8..4aeaea0 100755 --- a/add-site.sh +++ b/add-site.sh @@ -36,7 +36,7 @@ hostname=$(hostname -f) # Set up directory structure main_web_root="/var/www/$domain" -sudo mkdir -p "$main_web_root"/{_main/www,subdomains,logs} +sudo mkdir -p "$main_web_root"/{_main/www,subdomains,logs,nginx} # Create the user with the web root as home directory and add to www-data and websftpusers groups sudo useradd -m -d /var/www/$domain -s /bin/false -U -G www-data,websftpusers $username @@ -50,11 +50,16 @@ sudo find "$main_web_root" -type f -exec chmod 640 {} + # Set ownership and permissions for the main web root # SFTP chroot requires the user's home directory to be owned by root and not writable by others sudo chown "root:www-data" "$main_web_root" -sudo chmod 755 "$main_web_root" +sudo chmod 750 "$main_web_root" # Set ownership and permissions for the logs directory sudo chown root:www-data "$main_web_root/logs" -sudo chmod 755 "$main_web_root/logs" +sudo chmod 750 "$main_web_root/logs" + +# Set ownership and permissions for the nginx directory +sudo chown root:www-data "$main_web_root/nginx" +sudo chmod 750 "$main_web_root/nginx" +sudo chmod 640 "$main_web_root/nginx/*" # Create MySQL user and grant permissions sudo mysql <