user root; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { # upstream official_backend { # server localhost:3000 # 机器A的内网地址 # # server 10.0.0.15:3000; # 机器B的内网地址 # } log_format official_log '客户端IP: $remote_addr | 用户: $remote_user | 时间: $time_local | ' '请求方法和路径: "$request" | 状态码: $status | 响应大小: $body_bytes_sent | ' '来源页面: "$http_referer" | 客户端UA: "$http_user_agent" | ' '上游服务器: $upstream_addr | 上游响应耗时: $upstream_response_time | ' '请求总耗时: $request_time | Host: $host'; # 1. 强制 HTTP 转 HTTPS(统一跳转到 lessie.ai) # server { # listen 80; # server_name lessie.ai www.lessie.ai; # return 301 https://lessie.ai$request_uri; # } # 2. 统一将 www.lessie.ai 重定向到 lessie.ai server { listen 80; server_name www.lessie.ai; return 301 http://lessie.ai$request_uri; } # 3. 正式服务站点(http://lessie.ai) server { listen 80; server_name lessie.ai; # access_log /data/tengine/logs/lessie.ai.official.access.log official_log; # error_log /data/tengine/logs/lessie.ai.official.error.log; location /video/ { # root /data/tengine/html/lessie_official; root /app/public/vidio; expires 30d; add_header Cache-Control "public"; add_header Accept-Ranges bytes; } # 反向代理到后端服务器渲染的nuxt项目3000端口 location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } # 禁止 logo 缓存(默认给用户方形) location = /favicon.svg { # 判断 UA,如果是 Googlebot,改写路径 if ($http_user_agent ~* "(Googlebot|Bingbot)") { rewrite ^/favicon.svg$ /favicon-google.svg last; } proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; add_header Expires 0 always; } # Googlebot 专用 favicon 文件(圆形图标) location = /favicon-google.svg { # root /data/tengine/html/lessie_official; root /app/public; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; add_header Expires 0 always; } } }