├── .whitesource ├── Dockerfile ├── README.md ├── images └── screenshot.png └── root └── etc ├── apache2 ├── conf.d │ └── errordocs.conf ├── html │ └── index.html └── internal │ ├── 200.png │ ├── 403.html │ ├── 403.jpg │ ├── 404.html │ ├── 404.png │ ├── 500.html │ ├── 500.jpg │ ├── container.css │ └── container.js ├── run_always ├── 50-config-webdir └── 55-fix-html-dir ├── service └── apache2 └── sv └── apache2 └── run /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "scanSettings": { 3 | "baseBranches": [] 4 | }, 5 | "checkRunSettings": { 6 | "vulnerableCheckRunConclusionLevel": "failure", 7 | "displayMode": "diff" 8 | }, 9 | "issueSettings": { 10 | "minSeverityLevel": "LOW" 11 | } 12 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nimmis/alpine-micro 2 | 3 | MAINTAINER nimmis 4 | 5 | COPY root/. / 6 | 7 | RUN apk update && apk upgrade && \ 8 | 9 | # Make info file about this build 10 | printf "Build of nimmis/alpine-apache, date: %s\n" `date -u +"%Y-%m-%dT%H:%M:%SZ"` >> /etc/BUILD && \ 11 | 12 | apk add apache2 libxml2-dev apache2-utils && \ 13 | mkdir /web/ && chown -R apache.www-data /web && \ 14 | 15 | sed -i 's#^DocumentRoot ".*#DocumentRoot "/web/html"#g' /etc/apache2/httpd.conf && \ 16 | sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /etc/apache2/httpd.conf && \ 17 | sed -i 's#^ServerRoot .*#ServerRoot /web#g' /etc/apache2/httpd.conf && \ 18 | sed -i 's/^#ServerName.*/ServerName webproxy/' /etc/apache2/httpd.conf && \ 19 | sed -i 's#^IncludeOptional /etc/apache2/conf#IncludeOptional /web/config/conf#g' /etc/apache2/httpd.conf && \ 20 | sed -i 's#PidFile "/run/.*#Pidfile "/web/run/httpd.pid"#g' /etc/apache2/conf.d/mpm.conf && \ 21 | sed -i 's#Directory "/var/www/localhost/htdocs.*#Directory "/web/html" >#g' /etc/apache2/httpd.conf && \ 22 | sed -i 's#Directory "/var/www/localhost/cgi-bin.*#Directory "/web/cgi-bin" >#g' /etc/apache2/httpd.conf && \ 23 | 24 | sed -i 's#/var/log/apache2/#/web/logs/#g' /etc/logrotate.d/apache2 && \ 25 | sed -i 's/Options Indexes/Options /g' /etc/apache2/httpd.conf && \ 26 | 27 | rm -rf /var/cache/apk/* 28 | 29 | VOLUME /web 30 | 31 | EXPOSE 80 443 32 | 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Alpine microcontainer with Apache2 2 | 3 | This is a micro docker container ![](https://images.microbadger.com/badges/image/nimmis/alpine-apache.svg) based on Alpine OS and Apache version 2. 4 | 5 | There images are build on [nimmis/alpine-micro](https://hub.docker.com/r/nimmis/alpine-micro/) ![](https://images.microbadger.com/badges/image/nimmis/alpine-micro.svg) which are a modified version of Alpine OS with a working init process, cron, logrotate and syslog. All services are started by runit daemon, for more information about how it works and setup of new services please visit for more information. 6 | 7 | The container also have a backup system with cron schedule, number of copies to save etc, for information about the backup system please visit the [README.md for the backupsystem](https://github.com/nimmis/backup/blob/master/README.md) 8 | 9 | 10 | #### starting the container as a daemon 11 | 12 | docker run -d --name apache nimmis/alpine-apache 13 | 14 | This will start the container with apache process running, to access the container use 15 | 16 | docker exec -ti apache /bin/sh 17 | 18 | #### Static web folder 19 | 20 | The images exposes a volume at /web. The structure is 21 | 22 | | Directory | Function | 23 | | --------- | -------- | 24 | | /web/html | web root | 25 | | /web/cgi-bin | cgi bin folder | 26 | | /web/config | apache config directory | 27 | | /web/logs | apache log directory | 28 | | /web/internal | internal pages, error pages etc 29 | 30 | To use this start the container with 31 | 32 | docker run -d --name apache -v /path/to/web:/web nimmis/alpine-apache 33 | 34 | if the folders are missing they will be created each time the container is started. 35 | 36 | #### Accessing apache from outside the container 37 | 38 | To access the webserver from external you can the **-P/-p** paramter, with **-P** the ports 80 and 443 is automaticly exposed and assign a random port. 39 | 40 | or use the **-p** command to assign other ports, the syntax is 41 | 42 | -p : 43 | 44 | so to access the apache server port 80 on port 8080 you should use the command 45 | 46 | docker run -d --name apache -p 8080:80 nimmis/alpine-apache 47 | 48 | or assigning 80->80 and 443->443 use 49 | 50 | docker run -d --name apache -p 80:80 -p 443:443 nimmis/alpine-apache 51 | 52 | #### Successsful setup 53 | 54 | If everything worked and you were able to expose the correct port and type the correct adress in a webbrowser the following page should appear. 55 | 56 | ![screenshot](https://github.com/nimmis/docker-alpine-apache/blob/master/images/screenshot.png?raw=true "Screenshot") 57 | -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimmis/docker-alpine-apache/02f4b647a8eae28849c596053af46e9a87e7b816/images/screenshot.png -------------------------------------------------------------------------------- /root/etc/apache2/conf.d/errordocs.conf: -------------------------------------------------------------------------------- 1 | ErrorDocument 403 /internal/403.html 2 | ErrorDocument 404 /internal/404.html 3 | ErrorDocument 500 /internal/500.html 4 | 5 | Alias "/internal" "/web/internal" 6 | 7 | Options FollowSymLinks 8 | AllowOverride None 9 | Require all granted 10 | 11 | 12 | -------------------------------------------------------------------------------- /root/etc/apache2/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | It is working 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | Valid XHTML 1.0 Strict 24 |
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /root/etc/apache2/internal/200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimmis/docker-alpine-apache/02f4b647a8eae28849c596053af46e9a87e7b816/root/etc/apache2/internal/200.png -------------------------------------------------------------------------------- /root/etc/apache2/internal/403.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 15 | 16 | Access Denied 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 |
25 |
26 | Valid XHTML 1.0 Strict 27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /root/etc/apache2/internal/403.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimmis/docker-alpine-apache/02f4b647a8eae28849c596053af46e9a87e7b816/root/etc/apache2/internal/403.jpg -------------------------------------------------------------------------------- /root/etc/apache2/internal/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Page not found 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 |
16 |
17 | Valid XHTML 1.0 Strict 18 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /root/etc/apache2/internal/404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimmis/docker-alpine-apache/02f4b647a8eae28849c596053af46e9a87e7b816/root/etc/apache2/internal/404.png -------------------------------------------------------------------------------- /root/etc/apache2/internal/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | Internal Server Error 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | Valid XHTML 1.0 Strict 24 |
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /root/etc/apache2/internal/500.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimmis/docker-alpine-apache/02f4b647a8eae28849c596053af46e9a87e7b816/root/etc/apache2/internal/500.jpg -------------------------------------------------------------------------------- /root/etc/apache2/internal/container.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-repeat: no-repeat; 3 | background-color: #303030; 4 | font-family: sans-serif; 5 | } 6 | 7 | div { 8 | color: white ; 9 | } 10 | 11 | a:link { 12 | color: lightgray; 13 | } 14 | 15 | a:visited { 16 | color: lightblue; 17 | } 18 | 19 | a:hover { 20 | color: white; 21 | } 22 | 23 | .infotxt { 24 | float:right; 25 | text-align: center; 26 | width: 60%; 27 | margin: 5% auto 0; 28 | } 29 | 30 | #head { 31 | font-size:300%; 32 | } 33 | 34 | #urltag { 35 | color: #f05050; 36 | font-size:150%; 37 | text-shadow: 2px 2px 2px #000; 38 | } 39 | 40 | #reason { 41 | font-size:150%; 42 | } 43 | 44 | #footer { 45 | position : absolute; 46 | font-size: .6em; 47 | bottom : 0; 48 | height : 20px; 49 | margin-top : 40px; 50 | 51 | } 52 | 53 | #w3cs { 54 | position : absolute; 55 | font-size: .6em; 56 | bottom : 0; 57 | height : 60px; 58 | margin-top : 40px; 59 | } 60 | #pic { 61 | position:absolute; 62 | z-index: -1; 63 | } 64 | -------------------------------------------------------------------------------- /root/etc/apache2/internal/container.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | document.getElementById('urltag').innerHTML = document.location; // location.protocol + '//' + location.host; // 3 | setTimeout(function(){document.getElementById('pic').style.visibility = "visible";},800); 4 | setTimeout(function(){document.getElementById('urltag').style.visibility = "visible";},2000); 5 | setTimeout(function(){document.getElementById('reason').style.visibility = "visible";},2000); 6 | } 7 | -------------------------------------------------------------------------------- /root/etc/run_always/50-config-webdir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # popolate /web if empty 4 | 5 | if [ ! -d /web/config ]; then 6 | mkdir /web/config 7 | chown -R apache.www-data /web/config 8 | fi 9 | 10 | if [ ! -d /web/logs ]; then 11 | mkdir /web/logs 12 | chown -R apache.www-data /web/logs 13 | fi 14 | 15 | if [ ! -f /web/config/httpd.conf ]; then 16 | cp -R /etc/apache2/* /web/config/ 17 | chown -R apache.www-data /web/config 18 | # fix bug in httpd.conf 19 | sed -i 's/^Group apache/Group www-data/' /web/config/httpd.conf 20 | fi 21 | 22 | if [ ! -d /web/modules ]; then 23 | ln -s /usr/lib/apache2 /web/modules 24 | fi 25 | 26 | if [ ! -d /web/run ]; then 27 | mkdir /web/run 28 | mkdir /web/run/apache2 29 | fi 30 | 31 | if [ ! -d /web/cgi-bin ]; then 32 | mkdir /web/cgi-bin 33 | chown -R apache.www-data /web/cgi-bin 34 | fi 35 | 36 | if [ ! -d /web/internal ]; then 37 | mkdir /web/internal 38 | cp -RpP /etc/apache2/internal/* /web/internal/ 39 | chown -R apache.www-data /web/internal 40 | fi 41 | -------------------------------------------------------------------------------- /root/etc/run_always/55-fix-html-dir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # copy index.html if html directory does not exists 4 | 5 | if [ ! -d /web/html ]; then 6 | mkdir /web/html 7 | cp -RpP /etc/apache2/html/* /web/html/ 8 | chown -R apache.www-data /web/html 9 | fi 10 | -------------------------------------------------------------------------------- /root/etc/service/apache2: -------------------------------------------------------------------------------- 1 | ../sv/apache2 -------------------------------------------------------------------------------- /root/etc/sv/apache2/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | export APACHE_RUN_USER=apache 5 | export APACHE_RUN_GROUP=www-data 6 | export APACHE_PID_FILE=/web/run/apache2.pid 7 | export APACHE_RUN_DIR=/var/run/ 8 | export APACHE_LOCK_DIR=/var/lock/ 9 | export APACHE_LOG_DIR=/web/log/ 10 | 11 | export LANG=C 12 | export LANG 13 | 14 | exec /usr/sbin/httpd -DNO_DETACH -f /web/config/httpd.conf 15 | 16 | --------------------------------------------------------------------------------