fix: RateLimit graceful degradation on permission denied

Silence mkdir() with @ operator; guard file_put_contents with
is_writable() check. When storage/cache/rate_limit is not writable
by php-fpm, requests are allowed through instead of throwing
warnings that flood the nginx error log.
This commit is contained in:
Pontoporeia
2026-04-06 16:39:55 +02:00
parent 6a1b41ac93
commit 756ddb5765
4 changed files with 20 additions and 3 deletions

View File

@@ -42,6 +42,12 @@ if [ -d "/var/www/posterg/storage" ]; then
ok "Storage: 2775, databases: 660"
fi
# Ensure writable cache subdirectories exist for php-fpm (www-data)
mkdir -p /var/www/posterg/storage/cache/rate_limit
chown -R www-data:posterg /var/www/posterg/storage/cache
chmod -R 2775 /var/www/posterg/storage/cache
ok "Cache dirs: created and owned by www-data:posterg"
# ── Step 2: Nginx config ──────────────────────────────────────────────────────
printf "\n📋 Step 2: Deploying nginx configuration...\n"
printf "--------------------------------------------\n"

View File

@@ -82,6 +82,12 @@ if [ -d "$APP_DIR/storage" ]; then
ok "Storage: 2775, databases: 660"
fi
# Ensure writable cache subdirectories exist for php-fpm (www-data)
mkdir -p "$APP_DIR/storage/cache/rate_limit"
chown -R "$WEB_USER:$APP_GROUP" "$APP_DIR/storage/cache"
chmod -R 2775 "$APP_DIR/storage/cache"
ok "Cache dirs: created and owned by $WEB_USER:$APP_GROUP"
printf "\n"
ok "Setup complete."
printf "\nNext steps:\n"