@@ -31,7 +31,11 @@ RUN --mount=type=secret,id=nginx-crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode=0644
3131 && printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/app-protect/debian `lsb_release -cs` nginx-plus\n" > /etc/apt/sources.list.d/nginx-app-protect.list \
3232 && printf "deb [signed-by=/usr/share/keyrings/app-protect-security-updates.gpg] https://pkgs.nginx.com/app-protect-security-updates/debian `lsb_release -cs` nginx-plus\n" >> /etc/apt/sources.list.d/nginx-app-protect.list \
3333 && apt-get -y update \
34- && apt-get -y install app-protect app-protect-attack-signatures; fi \
34+ && apt-get -y install app-protect app-protect-attack-signatures \
35+ && chown $UID:0 /opt \
36+ && chmod g+w /opt \
37+ && chown -R $UID:0 /opt/app_protect \
38+ && chmod -R g+w /opt/app_protect; fi \
3539# Forward request logs to Docker log collector
3640 && ln -sf /dev/stdout /var/log/nginx/access.log \
3741 && ln -sf /dev/stderr /var/log/nginx/error.log \
@@ -40,7 +44,16 @@ RUN --mount=type=secret,id=nginx-crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode=0644
4044 curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor > /usr/share/keyrings/nginx-archive-keyring.gpg \
4145 && echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://packages.nginx.org/nginx-agent/debian/ `lsb_release -cs` agent" > /etc/apt/sources.list.d/nginx-agent.list \
4246 && apt-get -y update \
43- && apt-get -y install nginx-agent; fi
47+ && apt-get -y install nginx-agent \
48+ # implement changes required to run NGINX Agent as an unprivileged user
49+ && chown -R $UID:0 /etc/nginx-agent \
50+ && chmod -R g+w /etc/nginx-agent \
51+ && chown -R $UID:0 /var/lib/nginx-agent \
52+ && chmod -R g+w /var/lib/nginx-agent \
53+ && chown -R $UID:0 /var/log/nginx-agent \
54+ && chmod -R g+w /var/log/nginx-agent \
55+ && chown -R $UID:0 /var/run/nginx-agent \
56+ && chmod -R g+w /var/run/nginx-agent; fi
4457
4558# implement changes required to run NGINX as an unprivileged user
4659RUN rm /etc/nginx/conf.d/default.conf \
@@ -55,11 +68,7 @@ RUN rm /etc/nginx/conf.d/default.conf \
5568 && chown -R $UID:0 /usr/lib/nginx/modules \
5669 && chmod -R g+w /usr/lib/nginx/modules \
5770 && chown -R $UID:0 /etc/nms \
58- && chmod -R g+w /etc/nms \
59- && chown -R $UID:0 /etc/nginx-agent \
60- && chmod -R g+w /etc/nginx-agent \
61- && chown -R $UID:0 /var/lib/nginx-agent \
62- && chmod -R g+w /var/lib/nginx-agent
71+ && chmod -R g+w /etc/nms
6372
6473# Startup script
6574COPY ./container/start.sh /deployment/
0 commit comments