Post
by liuhu1985 » Thu Mar 06, 2025 10:43 pm
{
# Ensure Coraza WAF loads first (commented out)
# order coraza_waf first
}
https://xxxcom, https://www.xxx.com {
# Access log configuration
log {
output file /var/log/caddy/access.log {
roll_size 10MB
roll_keep 3
roll_keep_for 720h
}
format json
level INFO
}
# Website root directory
root * /var/www
# Coraza WAF configuration (commented out)
# coraza_waf {
# include /etc/caddy/coraza/coraza.conf
# include /etc/caddy/coreruleset/crs-setup.conf
# include /etc/caddy/coreruleset/rules/*.conf
# directives `
# SecRuleEngine On
# SecAction "id:900200,phase:1,nolog,pass,t:none,setvar:tx.anomaly_score_blocking=5"
# SecRule REQUEST_URI "^/superman" "id:1001,phase:1,pass,nolog,ctl:ruleEngine=Off"
# SecRule REQUEST_URI "^/index.php" "id:1002,phase:1,pass,nolog"
# SecUploadFileLimit 10485760
# `
# }
# Enable static file server
file_server
# Enable gzip compression
encode gzip
# Block access to system/storage/ directory
@block_storage {
path /var/storage/*
}
respond @block_storage "403 Forbidden" 403
# Ensure static assets are served directly instead of being processed by PHP
@static_files {
path_regexp /\.(ico|gif|jpg|jpeg|png|webp|js|css|svg)$
}
handle @static_files {
root * /var/www
file_server
}
# SEO-friendly URL rewrite rules
@rewrite {
not path /admin*
not path /image*
not path /catalog/view/theme*
not path /system*
not path /robots.txt
not path /sitemap.xml
not path /favicon.ico
not path /index.php
}
rewrite @rewrite /index.php?_route_={path}
# Ensure the request checks for static files before passing to PHP
try_files {path} {path}/ /index.php?{query}
# PHP processing
php_fastcgi unix//run/php/php8.3-fpm.sock
# TLS certificate management
tls {
issuer acme
}
}Thanks for your response! I’m still struggling with this part. Could you help modify the code?