Skip to content

Commit 4e6256e

Browse files
authored
Merge pull request #9 from devilbox/release-0.15
WIP: Add HTTPS support
2 parents 1b4ee3a + 21dea7e commit 4e6256e

24 files changed

Lines changed: 1436 additions & 715 deletions

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
elif [ "${TRAVIS_BRANCH}" == "master" ]; then
7272
docker build --no-cache=true -t "${IMAGE}:latest" . &&
7373
docker images;
74-
elif [[ ${TRAVIS_BRANCH} =~ ^(release[/-][.0-9]+)$ ]]; then
74+
elif [[ ${TRAVIS_BRANCH} =~ ^(release-[.0-9]+)$ ]]; then
7575
docker build --no-cache=true -t "${IMAGE}:${TRAVIS_BRANCH}" . &&
7676
docker images;
7777
else
@@ -91,7 +91,7 @@ jobs:
9191
elif [ "${TRAVIS_BRANCH}" == "master" ]; then
9292
echo "Pushing ${IMAGE}:latest" &&
9393
docker push "${IMAGE}:latest";
94-
elif [[ ${TRAVIS_BRANCH} =~ ^(release[/-][.0-9]+)$ ]]; then
94+
elif [[ ${TRAVIS_BRANCH} =~ ^(release-[.0-9]+)$ ]]; then
9595
echo "Pushing ${IMAGE}:${TRAVIS_BRANCH}" &&
9696
docker push "${IMAGE}:${TRAVIS_BRANCH}";
9797
else

Dockerfile

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,29 @@ MAINTAINER "cytopia" <cytopia@everythingcli.org>
33

44

55
###
6-
### Labels
6+
### Build arguments
77
###
8-
LABEL \
9-
name="cytopia's Apache 2.4 Image" \
10-
image="apache-2.4" \
11-
vendor="devilbox" \
12-
license="MIT" \
13-
build-date="2017-10-01"
8+
ARG VHOST_GEN_GIT_REF=0.5
9+
ARG CERT_GEN_GIT_REF=0.2
10+
11+
ENV BUILD_DEPS \
12+
git \
13+
make \
14+
wget
15+
16+
ENV RUN_DEPS \
17+
ca-certificates \
18+
python-yaml \
19+
supervisor
20+
21+
22+
###
23+
### Runtime arguments
24+
###
25+
ENV MY_USER=daemon
26+
ENV MY_GROUP=daemon
27+
ENV HTTPD_START="httpd-foreground"
28+
ENV HTTPD_RELOAD="/usr/local/apache2/bin/httpd -k restart"
1429

1530

1631
###
@@ -22,36 +37,31 @@ RUN set -x \
2237
&& apt-get update \
2338
&& apt-get upgrade -y \
2439
&& apt-get install --no-install-recommends --no-install-suggests -y \
25-
make \
26-
python-yaml \
27-
supervisor \
28-
wget \
29-
&& rm -rf /var/lib/apt/lists/* \
30-
&& apt-get purge -y --auto-remove
31-
32-
# vhost-gen
33-
RUN set -x \
34-
&& wget --no-check-certificate -O vhost_gen.tar.gz https://github.com/devilbox/vhost-gen/archive/master.tar.gz \
35-
&& tar xfvz vhost_gen.tar.gz \
36-
&& cd vhost-gen-master \
40+
${BUILD_DEPS} \
41+
${RUN_DEPS} \
42+
\
43+
# Install vhost-gen
44+
&& git clone https://github.com/devilbox/vhost-gen \
45+
&& cd vhost-gen \
46+
&& git checkout "${VHOST_GEN_GIT_REF}" \
3747
&& make install \
3848
&& cd .. \
39-
&& rm -rf vhost*gen*
40-
41-
# watcherd
42-
RUN set -x \
49+
&& rm -rf vhost*gen* \
50+
\
51+
# Install cert-gen
52+
&& wget --no-check-certificate -O /usr/bin/ca-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/ca-gen \
53+
&& wget --no-check-certificate -O /usr/bin/cert-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/cert-gen \
54+
&& chmod +x /usr/bin/ca-gen \
55+
&& chmod +x /usr/bin/cert-gen \
56+
\
57+
# Install watcherd
4358
&& wget --no-check-certificate -O /usr/bin/watcherd https://raw.githubusercontent.com/devilbox/watcherd/master/watcherd \
44-
&& chmod +x /usr/bin/watcherd
45-
46-
# cleanup
47-
RUN set -x \
48-
&& apt-get update \
49-
&& apt-get remove -y \
50-
make \
51-
wget \
52-
&& apt-get autoremove -y \
53-
&& rm -rf /var/lib/apt/lists/* \
54-
&& apt-get purge -y --auto-remove
59+
&& chmod +x /usr/bin/watcherd \
60+
\
61+
# Clean-up
62+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps \
63+
${BUILD_DEPS} \
64+
&& rm -rf /var/lib/apt/lists/*
5565

5666
# Add custom config directive to httpd server
5767
RUN set -x \
@@ -64,6 +74,18 @@ RUN set -x \
6474
echo "IncludeOptional /etc/httpd-custom.d/*.conf"; \
6575
echo "IncludeOptional /etc/httpd/conf.d/*.conf"; \
6676
echo "IncludeOptional /etc/httpd/vhost.d/*.conf"; \
77+
\
78+
echo "LoadModule ssl_module modules/mod_ssl.so"; \
79+
echo "LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" ;\
80+
echo "Listen 443"; \
81+
echo "SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \
82+
echo "SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES"; \
83+
echo "SSLHonorCipherOrder on"; \
84+
echo "SSLProtocol all -SSLv3"; \
85+
echo "SSLProxyProtocol all -SSLv3"; \
86+
echo "SSLPassPhraseDialog builtin"; \
87+
echo "SSLSessionCache \"shmcb:/usr/local/apache2/logs/ssl_scache(512000)\""; \
88+
echo "SSLSessionCacheTimeout 300"; \
6789
) >> /usr/local/apache2/conf/httpd.conf
6890

6991
# create directories
@@ -74,28 +96,31 @@ RUN set -x \
7496
&& mkdir -p /var/www/default/htdocs \
7597
&& mkdir -p /shared/httpd \
7698
&& chmod 0775 /shared/httpd \
77-
&& chown daemon:daemon /shared/httpd
99+
&& chown ${MY_USER}:${MY_GROUP} /shared/httpd
78100

79101

80102
###
81103
### Copy files
82104
###
83-
COPY ./data/vhost-gen/conf.yml /etc/vhost-gen/conf.yml
84105
COPY ./data/vhost-gen/main.yml /etc/vhost-gen/main.yml
85-
COPY ./data/supervisord.conf /etc/supervisord.conf
106+
COPY ./data/vhost-gen/mass.yml /etc/vhost-gen/mass.yml
107+
COPY ./data/create-vhost.sh /usr/local/bin/create-vhost.sh
108+
COPY ./data/docker-entrypoint.d /docker-entrypoint.d
86109
COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh
87110

88111

89112
###
90113
### Ports
91114
###
92115
EXPOSE 80
116+
EXPOSE 443
93117

94118

95119
###
96120
### Volumes
97121
###
98122
VOLUME /shared/httpd
123+
VOLUME /ca
99124

100125

101126
###

README.md

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
# Apache 2.4 Docker
1+
# Apache 2.4 Docker image
22

3-
[![Devilbox](https://raw.githubusercontent.com/cytopia/devilbox/master/.devilbox/www/htdocs/assets/img/devilbox_80.png)](https://github.com/cytopia/devilbox)
3+
[![Build Status](https://travis-ci.org/devilbox/docker-apache-2.4.svg?branch=master)](https://travis-ci.org/devilbox/docker-apache-2.4)
4+
[![release](https://img.shields.io/github/release/devilbox/docker-apache-2.4.svg)](https://github.com/devilbox/docker-apache-2.4/releases)
5+
[![Join the chat at https://gitter.im/devilbox/Lobby](https://badges.gitter.im/devilbox/Lobby.svg)](https://gitter.im/devilbox/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6+
[![Github](https://img.shields.io/badge/github-docker--apache--2.4-red.svg)](https://github.com/devilbox/docker-apache-2.4)
7+
[![](https://images.microbadger.com/badges/license/devilbox/apache-2.4.svg)](https://microbadger.com/images/devilbox/apache-2.4 "apache-2.4")
48

5-
<sub>This Docker image is part of the **[devilbox](https://github.com/cytopia/devilbox)**.</sub>
9+
**[devilbox/docker-apache-2.4](https://github.com/devilbox/docker-apache-2.4)**
610

7-
**[Apache 2.2](https://github.com/devilbox/docker-apache-2.2) | Apache 2.4 | [Nginx stable](https://github.com/devilbox/docker-nginx-stable) | [Nginx mainline](https://github.com/devilbox/docker-nginx-mainline)**
8-
9-
[![Build Status](https://travis-ci.org/devilbox/docker-apache-2.4.svg?branch=master)](https://travis-ci.org/devilbox/docker-apache-2.4) [![](https://images.microbadger.com/badges/version/devilbox/apache-2.4.svg)](https://microbadger.com/images/devilbox/apache-2.4 "apache-2.4") [![](https://images.microbadger.com/badges/image/devilbox/apache-2.4.svg)](https://microbadger.com/images/devilbox/apache-2.4 "apache-2.4") [![](https://images.microbadger.com/badges/license/devilbox/apache-2.4.svg)](https://microbadger.com/images/devilbox/apache-2.4 "apache-2.4")
11+
This image is based on the official **[Apache 2.4](https://hub.docker.com/_/httpd)** Docker image and extends it with the ability to have **virtual hosts created automatically**, as well as **adding SSL certificates** when creating new directories. For that to work, it integrates two tools that will take care about the whole process: **[watcherd](https://github.com/devilbox/watcherd)** and **[vhost-gen](https://github.com/devilbox/vhost-gen)**.
1012

11-
This image is based on the official **[Apache 2.4](https://hub.docker.com/_/httpd)** Docker image and extends it with the ability to have **virtual hosts created automatically** when adding new directories. For that to work, it integrates two tools that will take care about the whole process: **[watcherd](https://github.com/devilbox/watcherd)** and **[vhost-gen](https://github.com/devilbox/vhost-gen)**.
13+
From a users perspective, you mount your local project directory into the container under `/shared/httpd`. Any directory then created in your local project directory wil spawn a new virtual host by the same name. Additional settings such as custom server names, PHP-FPM or even different Apache templates per project are supported as well.
1214

13-
From a users perspective, you mount your local project directory into the Docker under `/shared/httpd`. Any directory then created in your local project directory wil spawn a new virtual host by the same name. Additional settings such as custom server names, PHP-FPM or even different Apache templates per project are supported as well.
14-
15-
----
15+
| Docker Hub | Upstream Project |
16+
|------------|------------------|
17+
| <a href="https://hub.docker.com/r/devilbox/apache-2.4"><img height="82px" src="http://dockeri.co/image/devilbox/apache-2.4" /></a> | <a href="https://github.com/cytopia/devilbox" ><img height="82px" src="https://raw.githubusercontent.com/devilbox/artwork/master/submissions_banner/cytopia/01/png/banner_256_trans.png" /></a> |
1618

17-
Find me on **[Docker Hub](https://hub.docker.com/r/devilbox/apache-2.4)**:
18-
19-
[![devilbox/apache-2.4](http://dockeri.co/image/devilbox/apache-2.4)](https://hub.docker.com/r/devilbox/apache-2.4/)
20-
21-
<small>**Latest build:** This container is built every night by [travis-ci](https://travis-ci.org/devilbox/docker-apache-2.4).</small>
19+
**[Apache 2.2](https://github.com/devilbox/docker-apache-2.2) | Apache 2.4 | [Nginx stable](https://github.com/devilbox/docker-nginx-stable) | [Nginx mainline](https://github.com/devilbox/docker-nginx-mainline)**
2220

2321
----
2422

@@ -29,12 +27,16 @@ Find me on **[Docker Hub](https://hub.docker.com/r/devilbox/apache-2.4)**:
2927

3028
1. Automated virtual hosts can be enabled by providing `-e MASS_VHOST_ENABLE=1`.
3129
2. You should mount a local project directory into the Docker under `/shared/httpd` (`-v /local/path:/shared/httpd`).
32-
3. You can optionally specify a global server name suffix via e.g.: `-e MASS_VHOST_TLD=.local`
30+
3. You can optionally specify a global server name suffix via e.g.: `-e MASS_VHOST_TLD=.loc`
3331
4. You can optionally specify a global subdirectory from which the virtual host will servve the documents via e.g.: `-e MASS_VHOST_DOCROOT=www`
34-
4. Allow the Docker to expose its port via `-p 80:80`.
35-
5. Have DNS names point to the IP address the docker runs on (e.g. via `/etc/hosts`)
32+
5. Allow the Docker to expose its port via `-p 80:80`.
33+
6. Have DNS names point to the IP address the container runs on (e.g. via `/etc/hosts`)
3634

37-
With the above described settings, whenever you create a local directory under your projects dir, such as `/local/path/mydir`, there will be a new virtual host created by the same name `http://mydir`. You can also specify a global suffix for the vhost names via `-e MASS_VHOST_TLD=.local`, afterwards your above created vhost would be reachable via `http://mydir.local`.
35+
With the above described settings, whenever you create a local directory under your projects dir
36+
such as `/local/path/mydir`, there will be a new virtual host created by the same name
37+
`http://mydir`. You can also specify a global suffix for the vhost names via
38+
`-e MASS_VHOST_TLD=.loc`, afterwards your above created vhost would be reachable via
39+
`http://mydir.loc`.
3840

3941
Just to give you a few examples:
4042

@@ -67,7 +69,7 @@ docker run -it \
6769
-p 80:80 \
6870
-e MASS_VHOST_ENABLE=1 \
6971
-e MASS_VHOST_DOCROOT=www \
70-
-e MASS_VHOST_TLD=.local \
72+
-e MASS_VHOST_TLD=.loc \
7173
-v /local/path:/shared/httpd \
7274
devilbox/apache-2.4
7375
```
@@ -99,7 +101,7 @@ PHP-FPM is not included inside this Docker container, but can be enabled to cont
99101

100102
#### Disabling the default virtual host
101103

102-
If you only want to server you custom projects and don't need the default virtual host, you can disable it by `-e MAIN_VHOST_DISABLE=1`.
104+
If you only want to server you custom projects and don't need the default virtual host, you can disable it by `-e MAIN_VHOST_ENABLE=0`.
103105

104106

105107
## Options
@@ -130,7 +132,10 @@ This Docker container adds a lot of injectables in order to customize it to your
130132

131133
| Variable | Type | Default | Description |
132134
|----------|------|---------|-------------|
133-
| MAIN_VHOST_DISABLE | bool | `0` | By default there is a standard (catch-all) vhost configured to accept requests served from `/var/www/default/htdocs`. If you want to disable it, set the value to `1`.<br/><strong>Note:</strong>The `htdocs` dir name can be changed with `MAIN_VHOST_DOCROOT`. See below. |
135+
| MAIN_VHOST_ENABLE | bool | `1` | By default there is a standard (catch-all) vhost configured to accept requests served from `/var/www/default/htdocs`. If you want to disable it, set the value to `0`.<br/><strong>Note:</strong>The `htdocs` dir name can be changed with `MAIN_VHOST_DOCROOT`. See below. |
136+
| MAIN_VHOST_SSL_TYPE | string | `plain` | <ul><li><code>plain</code> - only serve via http</li><li><code>ssl</code> - only serve via https</li><li><code>both</code> - serve via http and https</li><li><code>redir</code> - serve via https and redirect http to https</li></ul> |
137+
| MAIN_VHOST_SSL_GEN | bool | `0` | `0`: Do not generate an ssl certificate<br/> `1`: Generate self-signed certificate automatically |
138+
| MAIN_VHOST_SSL_CN | string | `localhost` | Comma separated list of CN names for SSL certificate generation (The domain names by which you want to reach the default server) |
134139
| MAIN_VHOST_DOCROOT | string | `htdocs`| This is the directory name appended to `/var/www/default/` from which the default virtual host will serve its files.<br/><strong>Default:</strong><br/>`/var/www/default/htdocs`<br/><strong>Example:</strong><br/>`MAIN_VHOST_DOCROOT=www`<br/>Doc root: `/var/www/default/www` |
135140
| MAIN_VHOST_TPL | string | `cfg` | Directory within th default vhost base path (`/var/www/default`) to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.<br/><strong>Resulting default path:</strong><br/>`/var/www/default/cfg` |
136141
| MAIN_VHOST_STATUS_ENABLE | bool | `0` | Enable httpd status page. |
@@ -141,7 +146,9 @@ This Docker container adds a lot of injectables in order to customize it to your
141146
| Variable | Type | Default | Description |
142147
|----------|------|---------|-------------|
143148
| MASS_VHOST_ENABLE | bool | `0` | You can enable mass virtual hosts by setting this value to `1`. Mass virtual hosts will be created for each directory present in `/shared/httpd` by the same name including a top-level domain suffix (which could also be a domain+tld). See `MASS_VHOST_TLD` for how to set it. |
144-
| MASS_VHOST_TLD | string | `.local`| This string will be appended to the server name (which is built by its directory name) for mass virtual hosts and together build the final domain.<br/><strong>Default:</strong>`<project>.local`<br/><strong>Example:</strong><br/>Path: `/shared/httpd/temp`<br/>`MASS_VHOST_TLD=.lan`<br/>Server name: `temp.lan`<br/><strong>Example:</strong><br/>Path:`/shared/httpd/api`<br/>`MASS_VHOST_TLD=.example.com`<br/>Server name: `api.example.com` |
149+
| MASS_VHOST_SSL_TYPE | string | `plain` | <ul><li><code>plain</code> - only serve via http</li><li><code>ssl</code> - only serve via https</li><li><code>both</code> - serve via http and https</li><li><code>redir</code> - serve via https and redirect http to https</li></ul> |
150+
| MASS_VHOST_SSL_GEN | bool | `0` | `0`: Do not generate an ssl certificate<br/> `1`: Generate self-signed certificate automatically |
151+
| MASS_VHOST_TLD | string | `.loc`| This string will be appended to the server name (which is built by its directory name) for mass virtual hosts and together build the final domain.<br/><strong>Default:</strong>`<project>.loc`<br/><strong>Example:</strong><br/>Path: `/shared/httpd/temp`<br/>`MASS_VHOST_TLD=.lan`<br/>Server name: `temp.lan`<br/><strong>Example:</strong><br/>Path:`/shared/httpd/api`<br/>`MASS_VHOST_TLD=.example.com`<br/>Server name: `api.example.com` |
145152
| MASS_VHOST_DOCROOT | string | `htdocs`| This is a subdirectory within your project dir under each project from which the web server will serve its files.<br/>`/shared/httpd/<project>/$MASS_VHOST_DOCROOT/`<br/><strong>Default:</strong><br/>`/shared/httpd/<project>/htdocs/` |
146153
| MASS_VHOST_TPL | string | `cfg` | Directory within your new virtual host to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.<br/>`/shared/httpd/<project>/$MASS_VHOST_TPL/`<br/><strong>Resulting default path:</strong><br/>`/shared/httpd/<project>/cfg/` |
147154

@@ -159,7 +166,8 @@ This Docker container adds a lot of injectables in order to customize it to your
159166

160167
| Docker | Description |
161168
|--------|-------------|
162-
| 80 | Apache listening Port |
169+
| 80 | HTTP listening Port |
170+
| 443 | HTTPS listening Port |
163171

164172

165173
## Examples
@@ -247,9 +255,30 @@ It allows any of the following combinations:
247255
## Version
248256

249257
```
250-
Server version: Apache/2.4.27 (Unix)
251-
Server built: Sep 19 2017 01:10:42
252-
Server's Module Magic Number: 20120211:68
258+
Server version: Apache/2.4.33 (Unix)
259+
Server built: Apr 30 2018 04:30:01
260+
Server's Module Magic Number: 20120211:76
253261
Server loaded: APR 1.5.1, APR-UTIL 1.5.4
262+
Compiled using: APR 1.5.1, APR-UTIL 1.5.4
263+
Architecture: 64-bit
254264
Server MPM: event
265+
threaded: yes (fixed thread count)
266+
forked: yes (variable process count)
267+
Server compiled with....
268+
-D APR_HAS_SENDFILE
269+
-D APR_HAS_MMAP
270+
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
271+
-D APR_USE_SYSVSEM_SERIALIZE
272+
-D APR_USE_PTHREAD_SERIALIZE
273+
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
274+
-D APR_HAS_OTHER_CHILD
275+
-D AP_HAVE_RELIABLE_PIPED_LOGS
276+
-D DYNAMIC_MODULE_LIMIT=256
277+
-D HTTPD_ROOT="/usr/local/apache2"
278+
-D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
279+
-D DEFAULT_PIDLOG="logs/httpd.pid"
280+
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
281+
-D DEFAULT_ERRORLOG="logs/error_log"
282+
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
283+
-D SERVER_CONFIG_FILE="conf/httpd.conf"
255284
```

build/docker-attach.sh

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)