diff --git a/add-site.sh b/add-site.sh index 89b8b70..d00d508 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,error-pages} # 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 @@ -82,6 +82,12 @@ Password: $password MySQL Username: $username MySQL Password: $mysql_password MySQL Host: $hostname + +Main web root: $main_web_root/_main/www +Subdomain web root: $main_web_root/subdomains/[subdomain]/www + +Custom error pages: $main_web_root/error-pages +Subdomain custom error pages: $main_web_root/subdomains/[subdomain]/error-pages EOL" sudo chown "$username:$username" "$info_file" sudo chmod 600 "$info_file" @@ -138,7 +144,9 @@ sudo systemctl reload nginx echo "Setup complete for $domain" echo "Access via SFTP at $hostname with the username $username and the password $password" echo "Main website files should be placed in: _main/www" +echo "Custom error pages can be placed in: error-pages" echo "Subdomain files should be placed in: subdomains/[subdomain]/www" +echo "Subdomain custom error pages can be placed in: subdomains/[subdomain]/error-pages" echo "Site information (including MySQL credentials) is stored in: $info_file" echo "Cloudflare credentials for this domain are stored in: $cf_credentials" echo "Logs are stored in: logs" diff --git a/install/nginx-snippets/error-pages.conf b/install/nginx-snippets/error-pages.conf index f3f9a6a..67a064f 100644 --- a/install/nginx-snippets/error-pages.conf +++ b/install/nginx-snippets/error-pages.conf @@ -1,9 +1,9 @@ -error_page 403 /error/403.html; -error_page 404 /error/404.html; -error_page 503 /error/503.html; -error_page 500 502 504 /error/50x.html; +error_page 403 /generic-error-page/403.html; +error_page 404 /generic-error-page/404.html; +error_page 503 /generic-error-page/503.html; +error_page 500 502 504 /generic-error-page/50x.html; -location ^~ /error/ { +location ^~ /generic-error-page/ { alias /var/www/error-pages/; internal; } \ No newline at end of file diff --git a/site-config.conf b/site-config.conf index 57623aa..99684a0 100644 --- a/site-config.conf +++ b/site-config.conf @@ -45,12 +45,22 @@ server { return 403; } + # Domain-specific error pages + error_page 403 /domain-error-page/403.html; + error_page 404 /domain-error-page/404.html; + error_page 503 /domain-error-page/503.html; + error_page 500 502 504 /domain-error-page/50x.html; + location ^~ /domain-error-page/ { + alias "/var/www/$DOMAIN/error-pages/"; + internal; + } + # Site-specific error pages - error_page 403 /error/403.html; - error_page 404 /error/404.html; - error_page 503 /error/503.html; - error_page 500 502 504 /error/50x.html; - location ^~ /error/ { + error_page 403 /site-error-page/403.html; + error_page 404 /site-error-page/404.html; + error_page 503 /site-error-page/503.html; + error_page 500 502 504 /site-error-page/50x.html; + location ^~ /site-error-page/ { alias "$site_root/error-pages/"; internal; }