Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make apache ports configurable #361

Open
wants to merge 6 commits into
base: v4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dockerfile.slim.apache
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ARG PHP_VERSION
ARG TARGETOS
ARG TARGETARCH
ARG BLACKFIRE_VERSION=1
ARG APACHE_PORT=80
ARG APACHE_PORT_HTTPS=443
ONBUILD ARG TARGETOS=${TARGETOS}
ONBUILD ARG TARGETARCH=${TARGETARCH}
ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
Expand All @@ -22,6 +24,8 @@ ENV TARGETOS=${TARGETOS}
ENV TARGETARCH=${TARGETARCH}
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
ENV PHP_VERSION=${PHP_VERSION}
ENV APACHE_PORT=${APACHE_PORT}
ENV APACHE_PORT_HTTPS=${APACHE_PORT_HTTPS}

# |--------------------------------------------------------------------------
# | Main PHP extensions
Expand Down Expand Up @@ -207,7 +211,7 @@ STOPSIGNAL SIGWINCH

COPY utils/apache2-foreground /usr/local/bin/

EXPOSE 80
EXPOSE ${APACHE_PORT} ${APACHE_PORT_HTTPS}

ENV APACHE_DOCUMENT_ROOT=

Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.slim.cli
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ARG PHP_VERSION
ARG TARGETOS
ARG TARGETARCH
ARG BLACKFIRE_VERSION=1
ARG APACHE_PORT=80
ARG APACHE_PORT_HTTPS=443
ONBUILD ARG TARGETOS=${TARGETOS}
ONBUILD ARG TARGETARCH=${TARGETARCH}
ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
Expand All @@ -22,6 +24,8 @@ ENV TARGETOS=${TARGETOS}
ENV TARGETARCH=${TARGETARCH}
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
ENV PHP_VERSION=${PHP_VERSION}
ENV APACHE_PORT=${APACHE_PORT}
ENV APACHE_PORT_HTTPS=${APACHE_PORT_HTTPS}

# |--------------------------------------------------------------------------
# | Main PHP extensions
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.slim.fpm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ARG PHP_VERSION
ARG TARGETOS
ARG TARGETARCH
ARG BLACKFIRE_VERSION=1
ARG APACHE_PORT=80
ARG APACHE_PORT_HTTPS=443
ONBUILD ARG TARGETOS=${TARGETOS}
ONBUILD ARG TARGETARCH=${TARGETARCH}
ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
Expand All @@ -22,6 +24,8 @@ ENV TARGETOS=${TARGETOS}
ENV TARGETARCH=${TARGETARCH}
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
ENV PHP_VERSION=${PHP_VERSION}
ENV APACHE_PORT=${APACHE_PORT}
ENV APACHE_PORT_HTTPS=${APACHE_PORT_HTTPS}

# |--------------------------------------------------------------------------
# | Main PHP extensions
Expand Down
6 changes: 5 additions & 1 deletion utils/Dockerfile.slim.blueprint
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ARG PHP_VERSION
ARG TARGETOS
mms-gianni marked this conversation as resolved.
Show resolved Hide resolved
ARG TARGETARCH
ARG BLACKFIRE_VERSION=1
ARG APACHE_PORT=80
ARG APACHE_PORT_HTTPS=443
ONBUILD ARG TARGETOS=${TARGETOS}
ONBUILD ARG TARGETARCH=${TARGETARCH}
ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
Expand All @@ -21,6 +23,8 @@ ENV TARGETOS=${TARGETOS}
ENV TARGETARCH=${TARGETARCH}
ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION}
ENV PHP_VERSION=${PHP_VERSION}
ENV APACHE_PORT=${APACHE_PORT}
ENV APACHE_PORT_HTTPS=${APACHE_PORT_HTTPS}

# |--------------------------------------------------------------------------
# | Main PHP extensions
Expand Down Expand Up @@ -206,7 +210,7 @@ STOPSIGNAL SIGWINCH

COPY utils/apache2-foreground /usr/local/bin/

EXPOSE 80
EXPOSE ${APACHE_PORT} ${APACHE_PORT_HTTPS}

ENV APACHE_DOCUMENT_ROOT=

Expand Down
11 changes: 11 additions & 0 deletions utils/README.blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@ APACHE_DOCUMENT_ROOT=public/
APACHE_DOCUMENT_ROOT=/var/www/html/public
```

## Changing Apache default ports

For the *apache* variant, you can change the default ports of Apache by using the `APACHE_PORT` and `APACHE_PORT_HTTPS` variables:

```bash
# The default port of Apache is 80
APACHE_PORT=8080
# The default SSL port of Apache is 443
APACHE_PORT_HTTPS=8443
```

## Enabling/disabling Apache extensions

You can enable/disable Apache extensions using the `APACHE_EXTENSION_[extension_name]` environment variable.
Expand Down
10 changes: 10 additions & 0 deletions utils/docker-entrypoint-as-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ else
export ABSOLUTE_APACHE_DOCUMENT_ROOT="/var/www/html/$APACHE_DOCUMENT_ROOT"
fi

if [[ "$APACHE_PORT" != "80" ]]; then
sudo sed -i 's/Listen 80/Listen \${APACHE_PORT}/g' /etc/apache2/ports.conf && \
sudo sed -i 's/VirtualHost *:80/VirtualHost *:\${APACHE_PORT}/g' /etc/apache2/sites-available/000-default.conf
fi

if [[ "$APACHE_PORT_HTTPS" != "443" ]]; then
sudo sed -i 's/Listen 443/Listen \${APACHE_PORT_HTTPS}/g' /etc/apache2/ports.conf && \
sudo sed -i 's/VirtualHost _default_:443/VirtualHost _default_:\${APACHE_PORT_HTTPS}/g' /etc/apache2/sites-available/default-ssl.conf
fi

# We should run the command with the user of the directory... (unless this is Apache, that must run as root...)
if [[ "$@" == "apache2-foreground" ]]; then
/usr/local/bin/apache-expose-envvars.sh;
Expand Down