Files
SupervisorAI/web_page/nginx.conf

91 lines
2.8 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配置文件 - 监控大屏系统
server {
listen 8093;
server_name localhost;
# 设置字符编码
charset utf-8;
# 设置根目录
root D:/code/python_project/FaceRecognitionWithInsightFace/web_page;
# 默认首页
index index.html monitor_dashboard.html;
# API代理配置 - 将/api路径路由到后端服务
location /api/ {
# 后端服务地址(请根据实际情况修改)
proxy_pass http://localhost:8000/api/;
# 代理设置
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;
# 超时设置
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
# 启用WebSocket支持如果需要
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# CORS支持
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Authorization";
# 处理预检请求
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Authorization";
add_header Access-Control-Max-Age 86400;
return 204;
}
}
# 主页面服务
location / {
try_files $uri $uri/ =404;
# 设置MIME类型
types {
text/html html htm;
text/css css;
application/javascript js;
image/png png;
image/jpeg jpg jpeg;
image/gif gif;
image/svg+xml svg;
}
# 启用gzip压缩
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# 缓存设置
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
# 静态资源目录
location /static/ {
alias D:/code/python_project/FaceRecognitionWithInsightFace/web_page/static/;
expires 1y;
add_header Cache-Control "public, immutable";
}
# 错误页面
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
# 日志设置Windows路径
access_log logs/monitor_dashboard_access.log;
error_log logs/monitor_dashboard_error.log;
}