From 16ffc23bc8b6432099dbad709ccc2382f59c397f Mon Sep 17 00:00:00 2001 From: pmsyffau9 <3396485415@qq.com> Date: Wed, 18 Dec 2024 19:46:17 +0800 Subject: [PATCH] Update nginx.conf --- front-end/mall4v/nginx.conf | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/front-end/mall4v/nginx.conf b/front-end/mall4v/nginx.conf index b7f87ed..d46aa84 100644 --- a/front-end/mall4v/nginx.conf +++ b/front-end/mall4v/nginx.conf @@ -1,22 +1,44 @@ +# 定义一个server块,它代表一个虚拟主机或站点。 server { + # 监听在HTTP标准端口80上,这是未加密的HTTP流量的标准端口。 listen 80; + + # 指定该服务器块响应哪些域名的请求。这里是mini-admin.mall4j.com。 server_name mini-admin.mall4j.com; + # 开启Gzip压缩功能,以减少传输的数据量,提高页面加载速度。 gzip on; + + # 如果存在预压缩的静态资源(如.html.gz),则优先提供这些压缩后的资源。 gzip_static on; + # 定义处理所有请求的location块。 location / { + # 尝试按照顺序查找文件:先找精确匹配的文件路径,然后是目录,最后尝试根路径。 try_files $uri $uri/ /; + + # 设置Web根目录的位置,即网站文件存放的目录。 root /usr/share/nginx/html/dist; + + # 当访问根路径时,默认提供的首页文件名。 index index.html; } + # 当出现404错误(找不到页面)时,重定向到指定的404错误页面。 error_page 404 /404.html; - location = /404-light.html { + + # 特别指定当访问路径为/404-light.html时的处理方式。 + location = /404-light.html { + # 这里没有额外配置,意味着它将按照默认规则处理此特定路径。 + # 使用"="表示精确匹配,只有当请求完全符合这个URL时才会触发。 } + # 对于500系列的服务器错误,重定向到指定的50x错误页面。 error_page 500 502 503 504 /50x.html; - location = /50x.html { + + # 特别指定当访问路径为/50x.html时的处理方式。 + location = /50x.html { + # 类似于上面的404-light.html配置,这里也没有额外配置。 + # "location = /50x.html"确保了只有当请求的是/50x.html时,才会应用这个location块。 } -} - +} \ No newline at end of file