Optimized for security and flexibility LAMP container based on Ubuntu
382
Optimized for flexibility and security. Best practices included.
Initially I've started it with Alpine Linux, but Apache package is quite bad there and was causing issues, so switched to Ubuntu.
You can either download the source and build it yourself or use the latest already built image to create container:
git clone https://github.com/kandev/lamp
cd lamp
Edit docker-compose.yml file and fill the path tou your volume mounts. We're keeping all important files out of the container.
docker-compose build
docker-compose up -d
docker create -h lamp01 --network dmz --ip 172.20.0.3 --name lamp01 -v /volumes/lamp1/www:/var/www:rw -v /volumes/lamp1/mysql:/var/lib/mysql:rw -v /volumes/lamp1/sites-enabled:/etc/apache2/sites-enabled:rw -v /volumes/lamp1/letsencrypt:/etc/letsencrypt:rw -v /etc/localtime:/etc/localtime:ro kandev/lamp:latest`
This config also expect you to have all local volume folders created:
mkdir -p /volumes/lamp1/letsencrypt
mkdir -p /volumes/lamp1/mysql
mkdir -p /volumes/lamp1/sites-enabled
mkdir -p /volumes/lamp1/www
/etc/apahce2/sites-enabled/domain.tld.conf (or use volume path, it's makes no difference)
<VirtualHost *:80>
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerName domain.tld
ServerAlias www.domain.tld
DocumentRoot /var/www/domain.tld
ErrorLog ${APACHE_LOG_DIR}/domain.tld-error.log
CustomLog ${APACHE_LOG_DIR}/domain.tld-access.log combined
SSLEngine on
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/mysql/cert.pem
SSLCertificateKeyFile /etc/mysql/key.pem
SSLProtocol TLSv1.2
Protocols h2 http/1.1
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
</VirtualHost>
This configuration will give you some green badges in most pentest/security scanners.
For the sake of passing the configcheck, this example uses the certificate generated for MariaDB during the creation of this image. It will be replaced by Certbot later.
You should restart the container after each configuration update.
From the host server run
docker exec -ti lamp01 bash
Assuming you named the container lamp01.
You should run this after the virtual host in Apache is configured.
certbot certonly --agree-tos --apache -n -d domain.tld,www.domain.tld
Then restart the container. Cron task will take care of regular renewing all installed certificates.
Content type
Image
Digest
Size
185.7 MB
Last updated
over 6 years ago
docker pull kandev/lamp