From 489075fc67a254e0039008148bc386343b3319c9 Mon Sep 17 00:00:00 2001 From: Lan Dong Si Hoang Date: Thu, 3 Sep 2020 15:46:24 +0700 Subject: [PATCH] Add support for http2 for Apache2 --- apache2/Dockerfile | 13 +++++++++++++ docker-compose.yml | 1 + env-example | 1 + 3 files changed, 15 insertions(+) diff --git a/apache2/Dockerfile b/apache2/Dockerfile index 7f0e6571..d31fcfe6 100644 --- a/apache2/Dockerfile +++ b/apache2/Dockerfile @@ -19,6 +19,19 @@ WORKDIR /var/www/ COPY vhost.conf /etc/apache2/sites-enabled/vhost.conf +ARG APACHE_INSTALL_HTTP2=false +RUN if [ ${APACHE_INSTALL_HTTP2} = true ]; then \ + mkdir /etc/apache2/ssl 2> /dev/null && \ + && openssl genrsa -out "/etc/apache2/ssl/ssl_site.key" 2048 \ + && openssl rand -out /root/.rnd -hex 256 \ + && openssl req -new -key "/etc/apache2/ssl/ssl_site.key" -out "/etc/apache2/ssl/ssl_site.csr" -subj "/CN=site.com/O=LGS/C=IT" \ + && openssl x509 -req -days 365 -in "/etc/apache2/ssl/ssl_site.csr" -signkey "/etc/apache2/ssl/ssl_site.key" -out "/etc/apache2/ssl/ssl_site.crt" \ + && a2enmod rewrite \ + && a2enmod headers \ + && a2enmod proxy proxy_html proxy_http xml2enc ssl http2 \ + && service apache2 restart \ +;fi + ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] CMD ["supervisord"] diff --git a/docker-compose.yml b/docker-compose.yml index 5221f87c..ffc3f92d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -388,6 +388,7 @@ services: - PHP_UPSTREAM_PORT=${APACHE_PHP_UPSTREAM_PORT} - PHP_UPSTREAM_TIMEOUT=${APACHE_PHP_UPSTREAM_TIMEOUT} - DOCUMENT_ROOT=${APACHE_DOCUMENT_ROOT} + - APACHE_INSTALL_HTTP2=${APACHE_INSTALL_HTTP2} volumes: - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG} - ${APACHE_HOST_LOG_PATH}:/var/log/apache2 diff --git a/env-example b/env-example index ef13d64b..60bbfc4f 100644 --- a/env-example +++ b/env-example @@ -302,6 +302,7 @@ APACHE_PHP_UPSTREAM_CONTAINER=php-fpm APACHE_PHP_UPSTREAM_PORT=9000 APACHE_PHP_UPSTREAM_TIMEOUT=60 APACHE_DOCUMENT_ROOT=/var/www/ +APACHE_INSTALL_HTTP2=false ### MYSQL #################################################