Skip to content

Commit 8ac53ff

Browse files
authored
feat: run nginx in non-privileged mode (#117)
- Frontend UIs (nginx): - container is run as `nginx(101)` user and `nginx(101)` group. - ownership of below directories/files are given to `nginx` user and group. - `/usr/share/nginx` - `/etc/nginx` - `/var/cache/nginx` - `/var/run/nginx.pid` - container binds to port `8080` instead of previous/default `80`. this is because port `80` is treated as a special port that requires elevated privileges/root.
1 parent d1b7443 commit 8ac53ff

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ COPY ["./nginx/mosaic-fe-samples.conf", "/etc/nginx/conf.d/"]
1111
# Copy build-artifact
1212
COPY ["./build", "/usr/share/nginx/html/"]
1313

14+
RUN chown -R nginx:nginx /usr/share/nginx && \
15+
chown -R nginx:nginx /etc/nginx && \
16+
chown -R nginx:nginx /var/cache/nginx && \
17+
touch /var/run/nginx.pid && \
18+
chown -R nginx:nginx /var/run/nginx.pid
19+
20+
USER nginx
21+
1422
CMD ["nginx", "-g", "daemon off;"]
1523

16-
EXPOSE 80/tcp
24+
EXPOSE 8080/tcp

nginx/mosaic-fe-samples.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
server {
2-
listen 80;
2+
listen 8080;
33

44
location / {
55
root /usr/share/nginx/html;

nginx/nginx.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ http {
2525

2626
gzip on;
2727

28+
server {
29+
listen 8081;
30+
}
31+
2832
include /etc/nginx/conf.d/*.conf;
2933
}

0 commit comments

Comments
 (0)