- 新增详细的 Fengling 项目文档,涵盖项目结构、技术栈、环境准备 - 包含后端与前端开发指南与规范说明 - 提供丰富的第三方组件安装及 Docker 容器部署示例 - 描述本地开发流程、测试策略及调试技巧 - 详细介绍生产环境部署、CI/CD 集成及云平台部署方案 - 增加监控、性能优化及故障排查的最佳实践 - 新建管理后台前端 Dockerfile 和对应 nginx 配置文件 - 新增项目快速启动的 README 指南,方便开发者快速上手
62 lines
1.8 KiB
Nginx Configuration File
62 lines
1.8 KiB
Nginx Configuration File
# nginx.conf for Vue applications
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
# 日志格式
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
access_log /var/log/nginx/access.log main;
|
|
error_log /var/log/nginx/error.log;
|
|
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout 65;
|
|
types_hash_max_size 2048;
|
|
|
|
# Gzip 压缩
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
|
|
|
|
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# 根路径
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html index.htm;
|
|
try_files $uri $uri/ /index.html; # 支持 Vue Router history 模式
|
|
}
|
|
|
|
# 静态资源缓存
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# API 代理 (开发时可能需要)
|
|
location /api/ {
|
|
proxy_pass http://backend:80;
|
|
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 500 502 503 504 /50x.html;
|
|
location = /50x.html {
|
|
root /usr/share/nginx/html;
|
|
}
|
|
}
|
|
} |