Instant Reverse Proxy with Docker

Recently I have been using Docker to build out an Apache reverse proxy in development. The advantages of using Docker in this scenario are:
  • Increased Security through isolation - Docker containers jail your application so that the main operating system hosting the container is protected. The containers are ephemeral and can be rebuilt in seconds. Some organizations rebuild their applications on a nightly basis.
  • Fast Deployment - Once your docker file is setup you can deploy docker containers in seconds. This makes it very simple to graduate changes from development to production or rebuild infrastructure in DR scenario
  • Cloud Friendly - Docker containers are very portable. If suddenly your organization wants to move to cloud infrastructure or hosting providers, it is a relatively simple task to move these containers. Additionally, cloud companies like Amazon, Azure are heavily invested in Docker and already have many of the tools in place for organizations using Docker.

What does this look like? To start we need to install Docker on Linux. In this example we are using Oracle Linux. Reference

Enable the ol7_addons channel in YUM. i.e. 

#Enable ol7_addons repo cat << EOF | sudo tee /etc/yum.repos.d/ol7_addons.repo
[ol7_addons]
name=Oracle Linux $releasever Add ons (\$basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/\$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
EOF
rpm --import http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7
yum makecache

Install the Docker engine for OEL via YUM and start the Docker Service.

yum install docker -y
systemctl enable docker.service
systemctl start docker.service

Next, we need to load up a Docker image. In this example we will use the Official Apache HTTP Server docker image from the Docker hub. In particular I like the alpine branch because it is only 26 MB's!.

docker run -dit --name apache -p 443:443 -p 80:80 httpd:alpine

Just like that, you now have an Apache server running. If you browse to your servers hostname, you will see a default page that says "It works". Next we want to rebuild our Apache container so that we can modify the configuration and html files. Copy your html to /etc/docker/apache/html and copy your configuration to /etc/docker/apache/conf. Once in place you can tell the container to look in(bind mount) these host paths for this info.

#stop and remove container
docker stop apache
docker rm apache
#rebuild container with bind mount
docker run -dit --restart=always -h apache --name="apache" \
-v /etc/docker/apache/html:/usr/local/apache2/htdocs/ \
-v /etc/docker/apache/conf:/usr/local/apache2/conf/ \
-p 443:443 -p 80:80 \
httpd:alpine

Now if you browse to your servers hostname, you will see your custom content. If you have any issues starting the container, run "docker logs apache". to view the output and debug. 

Now we're ready to add the Weblogic plugin for Apache to the container and proxy to the weblogic server.
  1. Download the Oracle WebLogic Web Server Plugins
  2. Setup your httpd.conf configuration to load the plugin and redirect to your weblogic server
  3. Rebuild your container and bind mount the apache modules directory to include all modules you want loaded on apache server. Include the weblogic plugin in this directory.

#stop and remove container
docker stop apache
docker rm apache
#rebuild container with bind mount
docker run -dit --restart=always -h apache --name="apache" \
-v /etc/docker/apache/html:/usr/local/apache2/htdocs/ \
-v /etc/docker/apache/conf:/usr/local/apache2/conf/ \
-v /etc/docker/apache/modules:/usr/local/apache2/modules \
-p 443:443 -p 80:80 \
httpd:alpine


I also see this as good preparation for what may be coming. It looks like PeopleTools will eventually be delivered in a Docker image.Why do I think this?
  •  If you open the DPK you will see references to Docker (likely used internally) 
  • Oracle clearly is moving in this direction as evidenced by their git hub repository. They already have officially supported Docker images for PeopleSoft core technologies, Oracle Weblogic, Oracle Tuxedo, and Oracle Database. 

Comments

Popular posts from this blog

Active Directory Authentication with an Oracle Database

Create a custom backup report with BI Publisher for Oracle Enterprise Manager/Cloud Control 13c

Oracle Enterprise Manager notify when Recovery Area low