refactor/nginx: 重构 NGINX 配置文件

-移除了不必要的全局配置,简化了配置文件结构
- 删除了未使用的日志格式和访问日志配置
- 移除了反向代理和日志文件访问相关配置
- 保留了基本的服务器配置和错误页面配置
This commit is contained in:
Huangzhe
2025-05-27 21:34:16 +08:00
parent e39982c6f5
commit 4d13a28eb2

View File

@@ -1,62 +1,21 @@
worker_processes 1;
server {
listen 80 default_server;
server_name _;
# 错误日志配置
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
events {
worker_connections 1024;
}
http {
# 访问日志格式定义
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;
server {
listen 80 default_server;
server_name _;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/html;
index index.html index.htm;
try_files $uri $uri/ //index.html;
}
# 跳转到伊利GPT
# 反向代理配置
location /aiagent/ {
proxy_pass https://yiligpt.x.digitalyili.com;
proxy_set_header Host yiligpt.x.digitalyili.com;
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;
# 如果需要忽略SSL证书验证测试环境
# proxy_ssl_verify off;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
# 提供日志文件访问
location /logs {
alias /var/log/nginx/;
autoindex on;
# 安全设置,根据需要取消注释
# auth_basic "Restricted Access";
# auth_basic_user_file /etc/nginx/.htpasswd;
}
location / {
root /var/www/html;
index index.html index.htm;
try_files $uri $uri/ //index.html;
}
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
}