Files
coolcoth.com/coolcoth.com.conf
T
Lucanlee d5c1edefae perf: V0.9.4 商品列表分页 + sitemap 文件缓存 + banner/asset/gzip/类型修复
- P1: Product::listing() 分页(WHERE status=1+LIMIT/OFFSET+总数),ProductController 改用并加翻页器,消除列表全表
- P1: outputSitemap() 加 storage/cache/sitemap.xml 文件缓存(TTL 3600s),消除每次爬虫全表
- P2: 首页 banner 改 whereLimit('status',1,20)
- P2: asset() 追加 ?v=filemtime 版本串,theme.css 改后自动击穿 1y 浏览器缓存
- P2: nginx 启用 gzip(文本资源压缩)
- P2: Model::count() $val 隐式可空改 mixed(PHP 8.4+ 弃用)
2026-08-08 23:53:52 +08:00

107 lines
4.7 KiB
Plaintext
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) 站点配置 coolcoth.com
# 运行目录 = /publicPHP 入口 index.php
# ------------------------------------------------------------
# 两种用法(二选一):
# A. 高级:宝塔 -> 网站 -> 设置 -> 配置文件,整体替换为下方完整 server 块
# B. 普通:宝塔新建站点后,仅把下方「伪静态区」内容粘到「伪静态」框,
# 再用「设置 -> 重定向」开启 https + www 跳转(见文件末尾说明)
# ============================================================
# ---------- 完整版 server 块(用法 A----------
server {
listen 80;
server_name coolcoth.com www.coolcoth.com;
# HTTP -> HTTPS,并规范到 www(延续原 Apache 的 www 优先策略)
return 301 https://www.coolcoth.com$request_uri;
}
server {
listen 443 ssl http2;
server_name coolcoth.com www.coolcoth.com;
root /www/wwwroot/coolcoth.com/public; # 运行目录 = /public
index index.php index.html;
# ── Gzip 压缩(V0.9.4:文本资源压缩,降低传输体积)──
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css text/xml application/xml application/javascript application/json application/x-javascript image/svg+xml;
# ── SSL 证书(宝塔申请 Let's Encrypt 后自动填充,或手动指定)──
# ssl_certificate /www/server/panel/vhost/cert/coolcoth.com/fullchain.pem;
# ssl_certificate_key /www/server/panel/vhost/cert/coolcoth.com/privkey.pem;
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ── 通用安全响应头(Nginx 层统一下发,含静态资源;
# CSP 含动态 nonce,由 PHP Helper::apply_security_headers() 下发,勿在此重复)──
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=(), payment=(), usb=()" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
# ── Let's Encrypt HTTP-01 验证(运行目录=/public 时必须,否则签发 404)──
location ^~ /.well-known/acme-challenge/ {
root /www/wwwroot/coolcoth.com; # 真实根目录(不含 /public)
default_type text/plain;
try_files $uri =404;
}
# ── 静态资源长缓存 ──
location ~* \.(css|js|png|jpg|jpeg|gif|svg|ico|webp|woff2?|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public";
}
# ── 前端控制器:真实文件直接服务,其余转发 index.php ──
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# ── PHP ──
location ~ \.php$ {
# 禁止敏感目录下的 PHP 被执行
location ~ /(app|config|storage|routes|vendor)/.*\.php$ { return 404; }
fastcgi_pass unix:/tmp/php-cgi-74.sock; # 按宝塔实际 PHP 版本调整(如 php-cgi-80.sock / php-cgi-82.sock
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# ── 禁止访问敏感文件 ──
location ~ \.(env|git|svn|htaccess|htpasswd|ini|log|bak|old|swp|sql|zip|gz|yml|md|lock|user\.ini)$ {
deny all;
}
}
# ============================================================
# 伪静态区(用法 B:粘贴到宝塔「伪静态」框)
# ------------------------------------------------------------
# location ^~ /.well-known/acme-challenge/ {
# root /www/wwwroot/coolcoth.com;
# default_type text/plain;
# try_files $uri =404;
# }
#
# location / {
# try_files $uri $uri/ /index.php?$query_string;
# }
#
# 安全响应头在宝塔「配置文件的 443 server 块」用 add_header ... always; 添加,
# 或保持现状由 PHP 下发(index.php 已全局调用 apply_security_headers())。
# ============================================================
#
# 用法 B 的「重定向」设置(宝塔 -> 网站 -> 设置 -> 重定向):
# 开启重定向 -> 名称任意 -> 类型 301
# 域名:coolcoth.com 目标 URLhttps://www.coolcoth.com$CACHE_URL$REQ_ARGS
# (宝塔会自动把 http:// 与 https:// 都重定向至 www;若想用裸域作主,目标改为 https://coolcoth.com
# ============================================================