guestbook/nginx.conf.example
Zhang Pu 06d21f90db init: guestbook v1.0.0 首次发布
- 加固版留言系统 / 磁盘清理助手
- MIT License
2026-11-02 11:12:15 +08:00

39 lines
1.1 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 留言系统 nginx 规则片段(贴到站点 server {} 里)
# 2026-10-30 · 配套 部署说明.md
# ⚠️ nginx 不读 .htaccess,这些规则必须显式配置
# 1) 数据库 / 日志 / 密钥 / 备份类文件一律封死
location ~* \.(db|sqlite|sqlite3|sql|log|ini|pem|key|p12|pfx|csr|bak|old|orig|swp|save)$ {
deny all;
return 404;
}
# 2) 压缩包类(防止把源码/备份打包下载)
location ~* \.(tar|gz|tgz|zip|7z|rar|iso)$ {
deny all;
return 404;
}
# 3) 留言本的数据目录(若把数据放在 webroot 内)
location ^~ /guestbook/data/ {
deny all;
return 404;
}
# 4) 留言本里的敏感文件(初始密码、说明文档、sql)
location ~* ^/guestbook/([^\/]*\.(sql|md|txt)|initial-admin-password\.txt)$ {
deny all;
return 404;
}
# 5) 点文件(.env/.git/.user.ini 等)—— 站点通用规则,注意不能误伤 .well-known
location ~ /\.(?!well-known) {
deny all;
return 404;
}
# 6) 防止上传目录执行脚本(若留言本后续加附件上传)
location ~* ^/guestbook/.*\.(php|phtml|php[3-8]|phar|cgi|pl|py|jsp|asp|aspx|sh|so)$ {
deny all;
return 404;
}