set capabilities for non root user to listen 443

This commit is contained in:
Vincent BRIDIER 2023-07-03 19:13:52 +02:00
parent a7d3ef9a39
commit 57fd4aac7e
No known key found for this signature in database
GPG key ID: 8571BFA20420D512
3 changed files with 13 additions and 5 deletions

View file

@ -1,4 +1,4 @@
FROM php:8.2-apache
FROM php:8.2-apache-bullseye
RUN apt-get update -qq && \
apt-get install -qy \
@ -27,7 +27,9 @@ RUN apt-get update -qq && \
# ldap
ldap-utils libldap2-dev \
# locales
locales
locales \
# libcap
libcap2-bin
# LOCALES
ENV DEBIAN_FRONTEND noninteractive
@ -53,7 +55,7 @@ RUN docker-php-ext-configure ldap
RUN docker-php-ext-install exif gd gettext intl mysqli pdo_mysql xsl opcache zip bcmath ldap
RUN pecl install imagick-3.6.0 && docker-php-ext-enable imagick
RUN pecl install memcached-3.1.5 && docker-php-ext-enable memcached
RUN pecl install memcached-3.2.0 && docker-php-ext-enable memcached
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@ -69,5 +71,11 @@ RUN a2enmod rewrite remoteip headers http2 && \
a2enconf z-app
RUN mkdir -p /app/tmp && chmod -R 770 /app/tmp && chown -R www-data:www-data /app
#Change access righs to conf, logs, bin from root to www-data
RUN chown -hR www-data:www-data /var/log/apache2
#setcap to bind to privileged ports as non-root
RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/apache2
USER www-data
WORKDIR /app/srcs

View file

@ -2,6 +2,6 @@
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 4433
Listen 443
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

View file

@ -1,4 +1,4 @@
<VirtualHost *:4433>
<VirtualHost *:443>
Protocols h2 h2c http/1.1
ServerAdmin contact@ldc.fr
DocumentRoot /app/srcs/public