Skip to content

Instantly share code, notes, and snippets.

@Llewellynvdm
Last active July 31, 2021 09:45
Show Gist options
  • Save Llewellynvdm/23dfbaf190567b0cd08841df0f5e0b73 to your computer and use it in GitHub Desktop.
Save Llewellynvdm/23dfbaf190567b0cd08841df0f5e0b73 to your computer and use it in GitHub Desktop.
Easy Joomla! 3.9.27 Docker Composer File

Apache Proxy Setup Instructions for Ubuntu 20.04

First Upate System:

$ sudo apt update
$ sudo apt upgrade -y

Install Apache:

$ sudo apt install -y apache2

Install build-essential:

$ sudo apt install -y build-essential

Install dependacies:

$ sudo apt install -y libapache2-mod-proxy-html libxml2-dev

Install Lego to setup Letsencypt Certificates (if you want SSL)

$ cd /tmp
$ curl -Ls https://api.github.com/repos/xenolf/lego/releases/latest | grep browser_download_url | grep linux_amd64 | cut -d '"' -f 4 | wget -i -
$ tar xf lego_vX.Y.Z_linux_amd64.tar.gz
$ sudo mkdir -p /home/user/cloud/letsencrypt
$ sudo mv lego /home/user/cloud/letsencrypt/lego
$ rm lego_vX.Y.Z_linux_amd64.tar.gz

readmore...

Configure Apache:

$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
$ sudo a2enmod proxy_ajp
$ sudo a2enmod rewrite
$ sudo a2enmod deflate
$ sudo a2enmod headers
$ sudo a2enmod ssl 
$ sudo a2enmod proxy_balancer
$ sudo a2enmod proxy_connect
$ sudo a2enmod proxy_html

Add the local.conf (details) to the correct path:

$ sudo nano /etc/apache2/sites-available/local.conf

OR Add the local-ssl.conf (details) to the correct path:

$ sudo nano /etc/apache2/sites-available/local-ssl.conf

Turn off the default website:

$ sudo a2dissite 000-default.conf

Turn on the local configurations:

$ sudo a2ensite local.conf

OR Turn on the local configurations:

$ sudo a2ensite local-ssl.conf

Setup the SSL with your docker container?

Depends on where in the container your application will get the keys.

Usually mounting files directly from the /home/user/cloud/letsencrypt/certificates folder, into your comtainer via the docker-compose.yml file will do.

Example:

volumes:
      - '/home/user/cloud/letsencrypt/certificates/jcb.yourdomain.com.crt:/opt/bitnami/apache/conf/server.crt'
      - '/home/user/cloud/letsencrypt/certificates/jcb.yourdomain.com.key:/opt/bitnami/apache/conf/server.key'

readmore...

Joomla Docker with Bitnami...

Restart Apache:

$ sudo service apache2 restart

That is all that is needed, you can add more proxies to the local.conf as needed, and just reload Apache each time.

version: '2'
services:
mariadb:
image: docker.io/bitnami/mariadb:10.3
restart: unless-stopped
environment:
- MARIADB_USER=JCB
- MARIADB_DATABASE=JCB
- MARIADB_PASSWORD=diegeheimewagwoord
- MARIADB_ROOT_PASSWORD=diegeheimewagwoord
volumes:
- '/home/user/cloud/mariadb:/bitnami/mariadb'
- '/home/user/cloud/conf/mariadb.cnf:/opt/bitnami/mariadb/conf/my_custom.cnf:ro'
joomla:
image: docker.io/bitnami/joomla:3
restart: unless-stopped
ports:
- '180:8080'
- '1443:8443'
environment:
- JOOMLA_DATABASE_HOST=mariadb
- JOOMLA_DATABASE_PORT_NUMBER=3306
- JOOMLA_DATABASE_USER=JCB
- JOOMLA_DATABASE_NAME=JCB
- JOOMLA_DATABASE_PASSWORD=diegeheimewagwoord
volumes:
- '/home/user/cloud/joomla:/bitnami/joomla'
- '/home/user/cloud/letsencrypt/certificates/jcb.yourdomain.com.crt:/opt/bitnami/apache/conf/server.crt'
- '/home/user/cloud/letsencrypt/certificates/jcb.yourdomain.com.key:/opt/bitnami/apache/conf/server.key'
depends_on:
- mariadb
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: unless-stopped
ports:
- '181:80'
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
UPLOAD_LIMIT: 300M
depends_on:
- mariadb
version: '2'
services:
JCB_web:
# image created for this task
image: vdmio/joomla:3.9.27-Stable
container_name: JCB_joomla
restart: unless-stopped
environment:
WEBSITEDOMAIN: jcb.yourdomain.com
WEBSITESNAME: "Joomla Component JCB"
WEBSITESUNAME: "Your Name"
WEBSITESUSERNAME: username
WEBSITESUSERPASS: diegeheimewagwoord
WEBSITESPASSRESET: 0
WEBSITESEMAIL: "[email protected]"
DBDRIVER: mysqli
DBHOST: JCB_mysql
DBUSER: JCB
DBPASS: diegeheimewagwoord
DBROOTPASS: diegeheimewagwoord
DBNAME: JCB
DBPREFIX: jcb
SMTPHOST: JCB_mailcatcher
STARTUP_COMMAND_1: deploy_joomla
links:
- JCB_mysql
- JCB_mailcatcher
depends_on:
- JCB_mysql
volumes:
# To set persistence
- '~/JCB_joomla:/var/www/html'
# To remove persistence
# - web-root:/var/www/html
networks:
- JCB-NETWORK
ports:
- 180:80
- 443:443
JCB_mysql:
image: mysql:5.7
container_name: JCB_mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: diegeheimewagwoord
volumes:
# To set persistence
- '~/JCB_db-data:/var/lib/mysql'
# To remove persistence
# - db-data:/var/www/html
networks:
- JCB-NETWORK
JCB_phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: JCB_phpmyadmin
restart: unless-stopped
environment:
PMA_HOST: JCB_mysql
PMA_PORT: 3306
# PMA_USER: root
# PMA_PASSWORD: diegeheimewagwoord
links:
- JCB_mysql
networks:
- JCB-NETWORK
ports:
- 181:80
JCB_mailcatcher:
image: schickling/mailcatcher
restart: unless-stopped
container_name: JCB_mailcatcher
networks:
- JCB-NETWORK
ports:
- 182:1080
networks:
JCB-NETWORK:
driver: bridge
ipam:
config:
- subnet: 172.16.12.0/24
# To remove persistence
# volumes:
# web-root:
# db-data
# jcb.yourdomain.com
<VirtualHost *:80>
ServerName jcb.yourdomain.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/jcb.yourdomain.com.error.log
CustomLog ${APACHE_LOG_DIR}/jcb.yourdomain.com.log combined
Redirect permanent / https://jcb.yourdomain.com
</VirtualHost>
<VirtualHost *:443>
ServerName jcb.yourdomain.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/jcb.yourdomain.com-error.log
CustomLog ${APACHE_LOG_DIR}/jcb.yourdomain.com-access.log combined
SSLEngine On
SSLCertificateFile /home/user/cloud/letsencrypt/certificates/jcb.yourdomain.com.crt
SSLCertificateKeyFile /home/user/cloud/letsencrypt/certificates/jcb.yourdomain.com.key
SSLCertificateChainFile /home/user/cloud/letsencrypt/certificates/jcb.yourdomain.com.issuer.crt
ProxyPreserveHost on
ProxyRequests off
SSLProxyEngine on
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPass / https://127.0.0.1:1443/
ProxyPassReverse / https://127.0.0.1:1443/
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ServerName jcb.yourdomain.com
ProxyPass / http://127.0.0.1:180/
ProxyPassReverse / http://127.0.0.1:180/
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ServerName db.yourdomain.com
ProxyPass / http://127.0.0.1:181/
ProxyPassReverse / http://127.0.0.1:181/
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ServerName mail.yourdomain.com
ProxyPass / http://127.0.0.1:182/
ProxyPassReverse / http://127.0.0.1:182/
</VirtualHost>
@ohrionmartin
Copy link

@Llewellynvdm
The correct path to add local.conf is in the /etc/apache2/sites-available directory instead of /etc/apache2/sites-enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment