ai_learn_node/nginx/nginx.conf.production
caoyuchun be1dab20e9 feat: 添加 Jenkins Docker 部署配置
- 添加 Jenkinsfile 和 Jenkinsfile.docker 支持 Docker 构建
- 添加 Docker Compose 生产环境配置
- 添加后端 Dockerfile
- 添加 Docker 部署脚本
- 添加部署文档 (JENKINS_DEPLOY.md, DOCKER_DEPLOY.md, DOCKER_ISOLATION.md)
- 更新 nginx 配置支持生产环境部署
2026-01-14 14:33:58 +08:00

129 lines
3.6 KiB
Plaintext
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学习平台生产环境
# 部署路径: /opt/nginx/html/ai/current
# 上游后端服务器
upstream backend {
server localhost:3001;
keepalive 64;
}
# HTTP 服务器配置
server {
listen 80;
server_name 180.76.180.105; # 服务器 IP 或域名
# 客户端最大请求体大小
client_max_body_size 10M;
# 日志配置
access_log /var/log/nginx/ai-learning-access.log;
error_log /var/log/nginx/ai-learning-error.log;
# 前端静态文件
location / {
root /opt/nginx/html/ai/current;
index index.html;
try_files $uri $uri/ /index.html;
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
# API 代理
location /api {
proxy_pass http://backend;
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;
proxy_cache_bypass $http_upgrade;
# 超时设置
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# 健康检查
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
# HTTPS 服务器配置(可选,需要 SSL 证书)
# server {
# listen 443 ssl http2;
# server_name 180.76.180.105; # 服务器 IP 或域名
#
# # SSL 证书配置
# ssl_certificate /path/to/your/certificate.crt;
# ssl_certificate_key /path/to/your/private.key;
#
# # SSL 优化配置
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# ssl_session_cache shared:SSL:10m;
# ssl_session_timeout 10m;
#
# # 客户端最大请求体大小
# client_max_body_size 10M;
#
# # 日志配置
# access_log /var/log/nginx/ai-learning-ssl-access.log;
# error_log /var/log/nginx/ai-learning-ssl-error.log;
#
# # 前端静态文件
# location / {
# root /opt/nginx/html/ai/current;
# index index.html;
# try_files $uri $uri/ /index.html;
#
# # 静态资源缓存
# location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
# expires 1y;
# add_header Cache-Control "public, immutable";
# }
# }
#
# # API 代理
# location /api {
# proxy_pass http://backend;
# 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;
# proxy_cache_bypass $http_upgrade;
#
# # 超时设置
# proxy_connect_timeout 60s;
# proxy_send_timeout 60s;
# proxy_read_timeout 60s;
# }
#
# # 健康检查
# location /health {
# access_log off;
# return 200 "healthy\n";
# add_header Content-Type text/plain;
# }
# }
#
# # HTTP 重定向到 HTTPS
# server {
# listen 80;
# server_name 180.76.180.105; # 服务器 IP 或域名
# return 301 https://$server_name$request_uri;
# }