Custom Domain for your Oracle 23ai Free APEX & ORDS all in one Docker Container with Apache HTTP


Following the prerequisites, its a fairly easy guide to get up and running, this time on Apache HTTP. OMG this is a super fast web-server.
Following this guide you’ll have a Vanity URL, proxied through Apache HTTP to your APEX instance.
Prerequisites
You’ve installed Docker-CE
You’ve installed Oracle 23ai Free Docker, APEX & ORDS all in one using my guide
You’ve got a (sub) Domain & Certificates
(Optional) You’ve configured ORDS for SSL on 9043 or otherwise use 8080
You’ve opened ports 80 & 443 for Apache
Steps
Connect to your instance
In bash run the following
nano setup-apache-ords.sh
Paste in the following
#!/bin/bash # Validate input arguments if [[ $# -ne 2 ]]; then echo "Usage: $0 <server.domain> <backend-address:port>" echo "Example: $0 example.com 192.168.1.100:8023" exit 1 fi SERVER_DOMAIN=$1 BACKEND_ADDRESS=$2 # Define project directory PROJECT_DIR="apache-ords" # Create the folder structure echo "Creating project directory structure..." mkdir -p $PROJECT_DIR/{conf,ssl} # Create `docker-compose.yml` DOCKER_COMPOSE_FILE=$PROJECT_DIR/docker-compose.yml cat <<EOL > $DOCKER_COMPOSE_FILE version: '3.9' services: apache: build: context: . container_name: apache-proxy ports: - "443:443" volumes: - ./ssl/cert.pem:/usr/local/apache2/ssl/cert.pem:ro - ./ssl/key.pem:/usr/local/apache2/ssl/key.pem:ro EOL echo "Created docker-compose.yml" # Create Dockerfile DOCKERFILE=$PROJECT_DIR/Dockerfile cat <<EOL > $DOCKERFILE FROM httpd:2.4 # Install net-tools to enable netstat and other network utilities RUN apt-get update && apt-get install -y net-tools nano # Enable SSL and proxy modules RUN sed -i '/Listen 80/a Listen 443' /usr/local/apache2/conf/httpd.conf && \ sed -i '/LoadModule ssl_module/s/^#//g' /usr/local/apache2/conf/httpd.conf && \ sed -i '/LoadModule rewrite_module/s/^#//g' /usr/local/apache2/conf/httpd.conf && \ sed -i '/LoadModule proxy_module/s/^#//g' /usr/local/apache2/conf/httpd.conf && \ sed -i '/LoadModule proxy_http_module/s/^#//g' /usr/local/apache2/conf/httpd.conf && \ sed -i '/LoadModule socache_shmcb_module/s/^#//g' /usr/local/apache2/conf/httpd.conf && \ echo "Include /usr/local/apache2/conf/extra/ssl-proxy.conf" >> /usr/local/apache2/conf/httpd.conf # Set ServerName globally to avoid warning about FQDN RUN echo "ServerName localhost" >> /usr/local/apache2/conf/httpd.conf # Create log directory and set permissions RUN mkdir -p /var/log/apache2 && \ chmod -R 755 /var/log/apache2 # Copy the custom SSL proxy configuration COPY conf/ssl-proxy.conf /usr/local/apache2/conf/extra/ssl-proxy.conf EOL echo "Created Dockerfile" # Create Apache configuration file APACHE_CONF_FILE=$PROJECT_DIR/conf/ssl-proxy.conf cat <<EOL > $APACHE_CONF_FILE <VirtualHost *:443> ServerName $SERVER_DOMAIN SSLEngine On SSLCertificateFile /usr/local/apache2/ssl/cert.pem SSLCertificateKeyFile /usr/local/apache2/ssl/key.pem # Enable proxying of HTTPS SSLProxyEngine On # Proxy settings ProxyPreserveHost On # Internal rewrite: requests to "/" are rewritten to "/ords/apex" RewriteEngine On # RewriteRule ^/$ /ords/ [R,L] RewriteRule ^/$ /ords/apex [R,L] # RewriteRule ^/$ /ords/r/workspace/landing [R,L] # Redirect to the specific landing page ProxyPass "/ords" $BACKEND_ADDRESS/ords ProxyPassReverse "/ords" $BACKEND_ADDRESS/ords ProxyPass "/i/" $BACKEND_ADDRESS/i/ ProxyPassReverse "/i/" $BACKEND_ADDRESS/i/ ErrorLog /usr/local/apache2/logs/error.log CustomLog /usr/local/apache2/logs/access.log combined </VirtualHost> EOL echo "Created Apache configuration file (ssl-proxy.conf)" # Placeholder SSL certificate and key files SSL_CERT_FILE=$PROJECT_DIR/ssl/cert.pem SSL_KEY_FILE=$PROJECT_DIR/ssl/key.pem echo "Creating placeholder SSL certificate and key files..." echo "-----BEGIN CERTIFICATE----- YOUR_CERTIFICATE_CONTENT_HERE -----END CERTIFICATE-----" > $SSL_CERT_FILE echo "-----BEGIN PRIVATE KEY----- YOUR_PRIVATE_KEY_CONTENT_HERE -----END PRIVATE KEY-----" > $SSL_KEY_FILE # Set permissions for SSL files chmod 600 $SSL_CERT_FILE $SSL_KEY_FILE echo "Setup complete! Your project is ready in the '$PROJECT_DIR' directory." # Instructions to build and run echo "To build and run your setup, execute the following commands:" echo "cd $PROJECT_DIR" echo "docker-compose up --build -d"
Make it executable
chmod +x setup-apache-ords.sh
Customize it before running it with your domain name & your IP address of your APEX box
./setup-apache-ords.sh example.com https://19.19.19.19:9043
this provides
Creating project directory structure... Created docker-compose.yml Created Dockerfile Created Apache configuration file (ssl-proxy.conf) Creating placeholder SSL certificate and key files... Setup complete! Your project is ready in the 'apache-ords' directory. To build and run your setup, execute the following commands: cd apache-ords docker-compose up --build -d
Copy your certificates to the folder
cp cert.pem apache-ords/ssl/cert.pem cp key.pem apache-ords/ssl/key.pem
Navigate to the
apache-ords
directory:cd apache-ords
Start docker-compose
docker-compose up --build -d
this produces
[+] Building 2.7s (11/11) FINISHED docker:default => [apache internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.28kB 0.0s => [apache internal] load metadata for docker.io/library/httpd:2.4 0.0s => [apache internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [apache 1/6] FROM docker.io/library/httpd:2.4 0.0s => [apache internal] load build context 0.0s => => transferring context: 183B 0.0s => CACHED [apache 2/6] RUN apt-get update && apt-get install -y net-tools nano 0.0s => CACHED [apache 3/6] RUN sed -i '/Listen 80/a Listen 443' /usr/local/apache2/conf/httpd.conf && sed -i '/LoadModule ssl_module/s/^#//g' /usr/local/apache2/conf/ 0.0s => CACHED [apache 4/6] RUN echo "ServerName localhost" >> /usr/local/apache2/conf/httpd.conf 0.0s => [apache 5/6] RUN mkdir -p /var/log/apache2 && chmod -R 755 /var/log/apache2 0.7s => [apache 6/6] COPY conf/ssl-proxy.conf /usr/local/apache2/conf/extra/ssl-proxy.conf 0.1s => [apache] exporting to image 1.7s => => exporting layers 1.7s => => writing image sha256:b028c8ea5bedf22b87c32a8f8d8e602439f2972e89468c320966909cf1ca5600 0.0s => => naming to docker.io/library/apache-ords-apache 0.0s [+] Running 2/2 ✔ Network apache-ords_default Created 0.5s ✔ Container apache-proxy Started
Test out your URL
ENJOY!
Whats the picture? Leeds train Station on a snowy day. Visit Yorkshire!
Subscribe to my newsletter
Read articles from Matt Mulvaney directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Matt Mulvaney
Matt Mulvaney
With around 20 years on the job, Matt is one of the most experienced software developers at Pretius. He likes meeting new people, traveling to conferences, and working on different projects. He’s also a big sports fan (regularly watches Leeds United, Formula 1, and boxing), and not just as a spectator – he often starts his days on a mountain bike, to tune his mind.