-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build a secure ESP docker image run as non-root (#563)
* Move server_config path to /home/nginx * start_esp add a flag --server_config_dir * fix start_esp test * create home folder for nginx user in deb.preinst * Build a separate secure image * Move default config_dir back to /etc/nginx
- Loading branch information
Showing
11 changed files
with
273 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Build more secure ESP docker image running as non-root | ||
# and allow root filesystem as read-only. | ||
|
||
FROM ${PARENT_IMAGE} | ||
|
||
RUN rm -rf /var/log/nginx && \ | ||
mkdir -p /var/log/nginx /var/cache/nginx && \ | ||
chown nginx:nginx /var/log/nginx /var/cache/nginx && \ | ||
chmod 777 /var/log/nginx /var/cache/nginx | ||
|
||
USER nginx | ||
|
||
ENTRYPOINT ["/usr/sbin/start_esp", "--server_config_dir=/home/nginx", "--config_dir=/home/nginx/endpoints"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#! /bin/sh | ||
# preinst script for nginx | ||
|
||
set -e | ||
|
||
addnginxuser() { | ||
# creating nginx group if he isn't already there | ||
if ! getent group nginx >/dev/null; then | ||
addgroup --system nginx >/dev/null | ||
fi | ||
|
||
# creating nginx user if he isn't already there | ||
if ! getent passwd nginx >/dev/null; then | ||
adduser \ | ||
--system \ | ||
--disabled-login \ | ||
--ingroup nginx \ | ||
--home /home/nginx \ | ||
--gecos "nginx user" \ | ||
nginx >/dev/null | ||
fi | ||
} | ||
|
||
case "$1" in | ||
install) | ||
addnginxuser | ||
cat <<BANNER | ||
---------------------------------------------------------------------- | ||
Thanks for using nginx! | ||
Please find the official documentation for nginx here: | ||
* http://nginx.org/en/docs/ | ||
Please subscribe to nginx-announce mailing list to get | ||
the most important news about nginx: | ||
* http://nginx.org/en/support.html | ||
Commercial subscriptions for nginx are available on: | ||
* http://nginx.com/products/ | ||
---------------------------------------------------------------------- | ||
BANNER | ||
;; | ||
upgrade) | ||
addnginxuser | ||
;; | ||
|
||
abort-upgrade) | ||
;; | ||
|
||
*) | ||
echo "preinst called with unknown argument \`$1'" >&2 | ||
exit 0 | ||
;; | ||
esac | ||
|
||
|
||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.