From cc98e5dccb2281904c2f65f4316edb232646d22f Mon Sep 17 00:00:00 2001 From: aaron <> Date: Wed, 12 Mar 2025 09:21:09 +0800 Subject: [PATCH] update --- Dockerfile | 7 ++++--- nginx.conf | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8c818c..85c587e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,10 +59,11 @@ RUN chown -R nginx:nginx /usr/share/nginx/html \ && chown -R nginx:nginx /var/log/nginx \ && chmod -R 755 /var/log/nginx \ && touch /var/run/nginx.pid \ - && chown -R nginx:nginx /var/run/nginx.pid + && chown -R nginx:nginx /var/run/nginx.pid \ + && chmod -R 755 /etc/nginx/conf.d -# 使用非root用户运行 -USER nginx +# 使用root用户运行nginx(标准做法) +# USER nginx EXPOSE 80 diff --git a/nginx.conf b/nginx.conf index 4c0c54e..7b1fe69 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,9 +1,12 @@ -# 移除 user 指令,因为我们以非 root 用户运行 -worker_processes auto; -pid /var/run/nginx.pid; +# 使用标准的nginx配置结构 +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; events { - worker_connections 1024; + worker_connections 1024; } http { @@ -15,7 +18,6 @@ http { '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; - error_log /var/log/nginx/error.log warn; sendfile on; keepalive_timeout 65;