Files
opencode b7613ba082 部署仓库初始化:epay 部署配置、补丁与插件
- docker-compose.prod.yml:挂载 epay-ui.css/js/head.php 补丁到 staging(镜像升级不丢)
- docker/nginx.conf:补丁静态资源 no-cache,改版立即生效
- patches/:
  - test.php 修复 paytype JSON 对象导致测试支付页空白
  - epay-ui.css 后台全屏/侧栏加宽/导航两列布局覆盖
  - epay-ui.js 去除页面容器宽度限制 + 侧栏当前菜单自动滚动
  - head.php 资源 ?v= 版本号强制回源
  - functions.php is_public_url 白名单等既有补丁
- plugins/ 支付插件源码
- .gitignore 排除 .env 等敏感与临时文件
2026-10-21 13:05:20 +08:00

128 lines
3.9 KiB
Nginx Configuration File
Raw Permalink 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 配置
# ============================================
upstream php-upstream {
server php:9000;
}
server {
listen 80;
server_name _;
root /var/www/html;
index index.php index.html;
charset utf-8;
client_max_body_size 50m;
# 反代环境下使用相对跳转,避免 301 到 http://
absolute_redirect off;
# ==========================================
# 信任宝塔 Nginx 反向代理传递的真实 IP
# ==========================================
set_real_ip_from 127.0.0.1;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
# ==========================================
# 安全响应头
# ==========================================
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
# ==========================================
# 安全规则:禁止直接访问核心目录
# ==========================================
location ^~ /includes {
deny all;
return 403;
}
location ^~ /plugins {
deny all;
return 403;
}
# install/index.php 在 install.lock 存在时自行拒绝重装;安装 SQL/锁文件不可下载。
location ~* ^/install/.*\.(sql|lock)$ {
deny all;
return 403;
}
# 保护敏感文件
location ~* /(config\.php|\.htaccess|\.git) {
deny all;
return 403;
}
# ==========================================
# URL 重写规则(对应 nginx.txt)
# ==========================================
location / {
# *.html → index.php?mod=xxx
if (!-e $request_filename) {
rewrite ^/(.[a-zA-Z0-9\-\_]+).html$ /index.php?mod=$1 last;
}
# /pay/xxx → pay.php?s=xxx
rewrite ^/pay/(.*)$ /pay.php?s=$1 last;
# /api/xxx → api.php?s=xxx
rewrite ^/api/(.*)$ /api.php?s=$1 last;
# /doc/xxx.html → index.php?doc=xxx
rewrite ^/doc/(.[a-zA-Z0-9\-\_]+).html$ /index.php?doc=$1 last;
try_files $uri $uri/ /index.php?$query_string;
}
# ==========================================
# PHP 处理
# ==========================================
location ~ \.php$ {
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# 安全:防止上传文件被执行
fastcgi_param PHP_VALUE "open_basedir=/var/www/html:/tmp/:/var/lib/php/sessions/";
}
# ==========================================
# 静态资源缓存
# ==========================================
# 前端补丁文件(后台布局 CSS/JS):始终回源校验,改版立即生效
location = /assets/dist/epay-ui.css {
add_header X-Content-Type-Options "nosniff" always;
add_header Cache-Control "no-cache" always;
}
location = /assets/dist/epay-ui.js {
add_header X-Content-Type-Options "nosniff" always;
add_header Cache-Control "no-cache" always;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
# ==========================================
# 上传目录:禁止执行 PHP
# ==========================================
location /assets/uploads/ {
location ~* \.php$ {
deny all;
return 403;
}
}
# ==========================================
# 日志
# ==========================================
access_log /var/log/nginx/epay-access.log;
error_log /var/log/nginx/epay-error.log;
}