初始化仓库及v1.0.0提交
This commit is contained in:
86
docs/baota-nginx-snippet.conf
Normal file
86
docs/baota-nginx-snippet.conf
Normal file
@@ -0,0 +1,86 @@
|
||||
# ============================================================
|
||||
# AI Chat 宝塔面板 Nginx 配置片段(PHP-FPM 版本)
|
||||
# ============================================================
|
||||
#
|
||||
# 【使用说明】
|
||||
# 1. 本文件为宝塔面板专用的 Nginx 配置片段,不是完整的站点配置文件。
|
||||
# 2. 使用步骤:
|
||||
# a. 在宝塔面板中创建网站,PHP 版本选择 PHP 8.0
|
||||
# b. 将网站根目录指向 /path/to/ai-chat/public
|
||||
# c. 登录宝塔面板 → 网站 → 找到你的站点 → 点击"设置"
|
||||
# d. 在左侧菜单选择"配置文件"
|
||||
# e. 将下方"配置内容开始"到"配置内容结束"之间的内容,
|
||||
# 复制并粘贴到 server { } 块内(注意不要重复嵌套 server 块)
|
||||
# f. 保存即可生效
|
||||
# 3. 前置准备:
|
||||
# - 在宝塔面板中安装 PHP 8.0 并启用
|
||||
# - 安装 MySQL 5.7+ 或 8.0
|
||||
# - 安装 Composer
|
||||
# - 运行 composer install 安装 PHP 依赖
|
||||
#
|
||||
# ============================================================
|
||||
|
||||
# ↓↓↓ 配置内容开始 ↓↓↓
|
||||
|
||||
# === AI Chat 网站配置(PHP-FPM) ===
|
||||
|
||||
# 1. 默认路由
|
||||
location / {
|
||||
try_files $uri $uri/ /login.php;
|
||||
}
|
||||
|
||||
# 2. API 路由 - 转发到 api.php
|
||||
location /api/ {
|
||||
try_files $uri /api.php$is_args$args;
|
||||
fastcgi_pass unix:/tmp/php-cgi-80.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/api.php;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param REQUEST_URI $request_uri;
|
||||
}
|
||||
|
||||
# 3. SSE 流式响应特殊配置(AI对话需要)
|
||||
# 针对 Chat API 的 SSE(Server-Sent Events)流式响应,
|
||||
# 需要禁用所有缓冲以确保实时输出
|
||||
location /api/chat/completions {
|
||||
fastcgi_pass unix:/tmp/php-cgi-80.sock;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/api.php;
|
||||
fastcgi_param REQUEST_URI $request_uri;
|
||||
# SSE 关键配置
|
||||
fastcgi_buffering off;
|
||||
proxy_buffering off;
|
||||
add_header X-Accel-Buffering no;
|
||||
# 超时设置(5分钟)
|
||||
fastcgi_read_timeout 300s;
|
||||
}
|
||||
|
||||
# 4. 静态资源缓存
|
||||
location /assets/ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 5. 上传文件访问
|
||||
location /uploads/ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# 6. 禁止访问非公开目录(安全)
|
||||
location ~ /(app|config|vendor|tests|scripts|)/ {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
# 7. 禁止访问隐藏文件
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
# 8. 上传文件大小限制
|
||||
client_max_body_size 10m;
|
||||
|
||||
# ↑↑↑ 配置内容结束 ↑↑↑
|
||||
Reference in New Issue
Block a user