Files
2026-02-11 14:55:11 +08:00

91 lines
2.9 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.

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;
}
}
}