From d49f856fd055554c2d8ea45bfd89e1ed0f31496a Mon Sep 17 00:00:00 2001 From: Huangzhe Date: Tue, 27 May 2025 21:58:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(docker):=20=E6=9B=B4=E6=96=B0=20Nginx=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=B9=B6=E6=B3=A8=E9=87=8A=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 default.conf 中添加了访问日志和错误日志配置 - 新增了日志文件访问接口 - 注释掉了 Dockerfile 中的配置文件复制指令 --- docker/Dockerfile | 2 +- docker/default.conf | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 53f2c05..1dce903 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,6 +14,6 @@ COPY ${DIST_DIR} /var/www/html/${URL_DIR} RUN sed -i "s/\ \/index.html/\ \/${URL_DIR}\/index.html/g" /etc/nginx/conf.d/default.conf # 默认不建议使用自定义nginx配置,如必须使用,请提前沟通 - COPY ./docker/default.conf /etc/nginx/conf.d/default.conf +# COPY ./docker/default.conf /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/docker/default.conf b/docker/default.conf index b65ea3a..420fb0b 100644 --- a/docker/default.conf +++ b/docker/default.conf @@ -11,6 +11,20 @@ server { try_files $uri $uri/ //index.html; } + # 启用访问日志,并指定日志文件路径和格式 + access_log /var/log/nginx/host.access.log; + + # 打印错误日志文件信息 + error_log /var/log/nginx/host.error.log; + location /yllog { + root /var/log/nginx; + autoindex on; + } + + # 定义日志格式(通常在 http 块中定义即可) + # log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html;