Skip to content

Commit 07c30d9

Browse files
authored
feat(security): do not run nginx as root (#227)
1 parent 203f273 commit 07c30d9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

openid-connect-provider-debugger/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
FROM openresty/openresty:1.27.1.2-4-alpine-fat@sha256:e93c5ab42fb6c7a882418c2bad0b39b566759f88c3fdd62f97264b621b6cba80
22

33
ARG LUA_RESTY_OPENIDC_VERSION="1.8.0-1"
4+
ARG USER_NAME=openresty
5+
ARG USER_HOME=/home/openresty
6+
ARG USER_ID=1000
7+
ARG USER_GECOS=OpenResty
48

59
SHELL ["/bin/ash", "-euo", "pipefail", "-c"]
610

@@ -29,4 +33,18 @@ COPY default.conf /etc/nginx/conf.d/
2933

3034
COPY index.html error.html /usr/local/openresty/nginx/html/
3135

36+
RUN adduser \
37+
--home "${USER_HOME}" \
38+
--uid "${USER_ID}" \
39+
--gecos "${USER_GECOS}" \
40+
--disabled-password \
41+
"${USER_NAME}" \
42+
&& chown -R "${USER_NAME}:${USER_NAME}" /var/run/openresty /usr/local/openresty/nginx/logs
43+
44+
USER "${USER_NAME}"
45+
46+
ENV HOME="${USER_HOME}"
47+
48+
WORKDIR "${HOME}"
49+
3250
EXPOSE 80 443

openid-connect-provider-debugger/nginx.conf.patch

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
--- /usr/local/openresty/nginx/conf/nginx.conf 2020-05-14 13:27:29.168451660 -0700
22
+++ /usr/local/openresty/nginx/conf/nginx.conf 2020-05-14 13:28:29.583197857 -0700
3-
@@ -24,6 +24,17 @@
3+
@@ -24,6 +24,19 @@
44

55

66

77
+error_log /dev/stderr debug;
88
+
9+
+user openresty;
10+
+
911
+env oidc_client_id;
1012
+env oidc_client_secret;
1113
+env oidc_discovery;

0 commit comments

Comments
 (0)