This commit is contained in:
aaron 2025-03-12 09:21:09 +08:00
parent 91e5dce938
commit cc98e5dccb
2 changed files with 11 additions and 8 deletions

View File

@ -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

View File

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