PetAgent/nginx.conf
taiyi 0ec37d6a56 解除“文件过大”限制
在 nginx.conf 里加了 client_max_body_size 1024m;
这样前端上传大视频时,不会再被 Nginx 在入口处直接拦截
修复视频背景边缘被裁剪、画面变模糊
后台管理页的视频预览改成了 object-fit: contain,避免把边缘裁掉
聊天页沉浸式视频背景也改成了 object-fit: contain + object-position: center center
同时给视频背景加了黑色底,避免留白时观感突兀
2026-05-23 15:24:27 +08:00

82 lines
2.3 KiB
Nginx Configuration File
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配置示例 - AI Pet Companion
# 用于部署到服务器 8.152.169.84
server {
listen 80;
server_name 8.152.169.84;
client_max_body_size 1024m;
# 前端静态文件
location / {
root /path/to/your/frontend/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
# API代理到后端
location /api/ {
proxy_pass http://localhost:8001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket支持
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# WebSocket连接
location /ws/ {
proxy_pass http://localhost:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 上传文件访问
location /uploads/ {
proxy_pass http://localhost:8001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 错误页面
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
# HTTPS配置示例 (如果需要SSL)
# server {
# listen 443 ssl;
# server_name 8.152.169.84;
#
# ssl_certificate /path/to/your/certificate.crt;
# ssl_certificate_key /path/to/your/private.key;
#
# # 其他配置同上...
# }
# WebSocket测试配置
# 如果遇到WebSocket连接问题可以尝试添加这些配置
#
# location /api/v1/voice/realtime/ {
# proxy_pass http://localhost:8001;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# proxy_set_header Host $host;
# proxy_read_timeout 86400;
# proxy_send_timeout 86400;
# }