Use authbind to bind privileged ports
This commit is contained in:
parent
e2f5d9066e
commit
b148f113ae
14 changed files with 48 additions and 69 deletions
|
|
@ -20,14 +20,13 @@ WORKDIR /etc/nginx
|
|||
|
||||
RUN clean-install \
|
||||
diffutils \
|
||||
libcap2-bin \
|
||||
dumb-init
|
||||
|
||||
COPY . /
|
||||
|
||||
# Fix permission during the build to avoid issues at runtime
|
||||
# with volumes (custom templates)
|
||||
RUN bash -eux -c ' \
|
||||
RUN bash -eu -c ' \
|
||||
writeDirs=( \
|
||||
/etc/nginx/template \
|
||||
/etc/ingress-controller/ssl \
|
||||
|
|
@ -41,9 +40,11 @@ RUN bash -eux -c ' \
|
|||
chown -R www-data.www-data ${dir}; \
|
||||
done' \
|
||||
&& chown www-data.www-data /etc/nginx/nginx.conf \
|
||||
&& chown www-data.www-data /etc/nginx/opentracing.json \
|
||||
&& chown www-data.www-data /etc/nginx
|
||||
&& chown www-data.www-data /etc/nginx/opentracing.json
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
# Create symlinks to redirect nginx logs to stdout and stderr docker log collector
|
||||
# This only works if nginx is started with CMD or ENTRYPOINT
|
||||
RUN ln -sf /dev/stdout /var/log/nginx/access.log
|
||||
RUN ln -sf /dev/stderr /var/log/nginx/error.log
|
||||
|
||||
CMD ["/nginx-ingress-controller"]
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
#!/usr/bin/dumb-init /bin/bash
|
||||
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -e
|
||||
|
||||
echo 0 > /tmp/nginx.pid
|
||||
# fix directory permissions
|
||||
writeDirs=( \
|
||||
/var/log
|
||||
/var/log/nginx
|
||||
/tmp
|
||||
);
|
||||
for dir in "${writeDirs[@]}";do
|
||||
mkdir -p ${dir};
|
||||
chown -R www-data.www-data ${dir};
|
||||
done
|
||||
|
||||
ln -sf /dev/stdout /var/log/nginx/access.log
|
||||
ln -sf /dev/stderr /var/log/nginx/error.log
|
||||
chown www-data.www-data /var/log/nginx/*
|
||||
|
||||
echo "Testing if setcap is supported..."
|
||||
if setcap cap_net_bind_service=+ep /usr/sbin/nginx; then
|
||||
echo "setcap is supported. Setting cap_net_bind_service=+ep to allow binding port lower than 1024 as non-root"
|
||||
setcap cap_net_bind_service=+ep /usr/sbin/nginx
|
||||
setcap -v cap_net_bind_service=+ep /usr/sbin/nginx
|
||||
setcap cap_net_bind_service=+ep /nginx-ingress-controller
|
||||
setcap -v cap_net_bind_service=+ep /nginx-ingress-controller
|
||||
|
||||
echo "Droping root privileges and running as user..."
|
||||
su-exec www-data:www-data "$@"
|
||||
else
|
||||
echo "WARNING!!!: setcap is not supported. Running as root"
|
||||
echo "Please check https://github.com/moby/moby/issues/1070"
|
||||
"$@"
|
||||
fi
|
||||
|
|
@ -131,6 +131,7 @@ http {
|
|||
client_body_temp_path /tmp/client-body;
|
||||
fastcgi_temp_path /tmp/fastcgi-temp;
|
||||
proxy_temp_path /tmp/proxy-temp;
|
||||
ajp_temp_path /tmp/ajp-temp;
|
||||
|
||||
client_header_buffer_size {{ $cfg.ClientHeaderBufferSize }};
|
||||
client_header_timeout {{ $cfg.ClientHeaderTimeout }}s;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue