Apache Web Server Docker



  • AWS, Docker

Introduction

Tutorial Apache - Testing the Docker installation Open your browser and enter the IP address of your web server. In our example, the following URL was entered in the Browser. Above docker compose file has settings for two containers. The first container is for mysql database server and the second is for web server. The web container will run our application on Apache server. As this is customized we have defined build directory to webapp. Step 4 – Build Webapp Image. Now, build an image using the following command. The Apache HTTP Server, colloquially called Apache, is a Web server application notable for playing a key role in the initial growth of the World Wide Web. Originally based on the NCSA HTTPd server, development of Apache began in early 1995 after work on the NCSA code stalled. Apache quickly overtook NCSA HTTPd as the dominant HTTP server, and has remained the most popular HTTP server in use sinc.

Docker is an open source platform which can be used to run/test applications in an isolated environment on the host system. Docker could be defined as an implementation of container using the concept of images.

Steps To Build Apache Web Server Docker Image | By Vikash ..

Unlike VM which is a complete OS intalled on host system managed by hypervisors and needs dedicated resources from the host machine, docker uses Linux Containers which directly interacts with the linux kernel like any other process on linux to request resources.

Scenario

Install apache inside a docker container on ec2 instance running Ubuntu (ami-ca381398) and access it using the hosts public IP.

Installing Docker: Run the following commands on terminal to install the docker.

Run following command to verify the successful installation of docker

We would see the following output on terminal which would list the version of docker installed on the system.

Fowarding Traffic: We need to foward all traffic to docker which we be required as we are running apache web server inside docker container.Enable forwarding with UFW(Uncomplicated Firewall): Citizen printers driver download for windows 10.

Replace “DEFAULT_FORWARD_POLICY=”DROP”” with “DEFAULT_FORWARD_POLICY=”ACCEPT” and save the file.

Search Docker Images: We would need to download Ubuntu image on host Ubuntu system on which we would install Apache web server. Varoius customize docker images are available on Docker repository which could be searched using the following command. This command would search and list all images having Ubuntu string in their name.

Download Ubuntu Image: This command would download Ubuntu version 14.04 image.

We can get list of all available images on our local system using:

In the above output, we can see the image id (2d24f826cb16) which is unique for every image. Just to compare, the size of this image is 192.7MB which is very small than than it’s VM image.

Now ,we have Ubuntu image which we would use to run container inside it and install Apache inside this container.

Example: We would take a simple example to run an application inside container which would print “hello”.

docker run: run applications inside containers.

2d24f826cb16: The image which we want to use to run container inside. We have used image id of the downloaded Ubuntu. We can either use image id or image name i.e. ubuntu:14.04.
echo “hello”: the command we want to run inside the container.

Docker container would be active until the command we ran is active. We can check the status of the exited/running containers using:

The above output says container with id 6cd7aacb64fb has been exited a minute ago. Like images, containers do have unique container id and name (backstabbing_sinoussi in this case). These name are automatically generated by docker. We can provide custom name using “–name” option n the docker run command.

In our case we need a container where we can install Apache web server and configure it the way we want. To achieve this we need an interactive container.

This command would get us an interactive container.

-t : assigns a terminal inside the container.
-i : create a interactive connection with container by grabbing STDIN.
/bin/bash : this command would launch bash shell inside container.

Now we are inside container. Type exit to come out of the container.

Before moving ahead, we would need the 80 port of host machine to be mapped with the 80 port of our container since we would be using host’s public ip and 80 port to take in requests and host would forward these requests to the Apache web server running at port 80 of container.

This commands would create container name “WebServer” and map the ports.

-p: maps the host’s 80 port with 80 port of container

Apache

Now we are inside the container. We would need to install Apache inside it and start it.

Apache On Docker

Centos

Now try to access the webserver using the public ip of host system in web browser.

Please verify 80 port is open on the security group of the ec2 instance of host system.

Now, the web server should work fine.

Press Ctrl+p and Ctrl+q to come out of the container. This would keep the container running behind. We can verify it using

The status WebServer container is “Up” and is running from last 9 minutes.

If we again need to make some changes inside this container, we need to attach to this container using docker attach command.

We can save this “Webserver” Container as image using docker commit command.

-m : for description of image

-a : Name of the Author
8931afa5aaa6 : container’s ip whose image we are creating.
ubuntu:Apache : specified the image name as “ubuntu” and tag as “Apache”

We can see this image using:

We would continue with some more scenarios in the next blog which would cover the creating image using dockerfile and allowing communication between two docker containers.

Check out our blog Amazon EC2 Container Service (ECS) – Docker Container Management

Spreed is a free open-source (AGPL) WebRTC audio/video call and conferencing server designed with privacy in mind. WebRTC is a free and open technology allows browsers to talk to each other in a peer-to-peer fashion. Spreed WebRTC server uses end-to-end encryption to protect users’ privacy and security.

Spreed WebRTC allows you to do the following things.

  • Secure audio, video and text chat
  • Web conferencing
  • One to one video chat

In a previous tutorial, we discussed how to install Spreed WebRTC server on Ubuntu 16.04 using the official PPA. This tutorial is going to show you how to install Spreed WebRTC server on Ubuntu using Docker image.

Why use Docker? The Spreed PPA only works on Ubuntu 16.04, so if you use Ubuntu 20.04, 18.04, or any other distro, you can’t use the PPA. The advantage of Docker is that it doesn’t matter whether you are using Debian, Ubuntu, CentOS, Redhat, SUSE, or whatever, as long as your distribution can run Docker engine, you can install Spreed WebRTC on it.

Step 1: Install Docker on Ubuntu

If you want the latest Docker version, you can install Docker from Docker’s APT repository. For simplicity, this tutorial installs Docker from the default Ubuntu software repository.

Once installed, the Docker daemon should be automatically started. You can check its status with:

Hint: If the above command doesn’t quit immediately, you can press the Q key to make it quit.

If it’s not running, then start the daemon with this command:

And enable autostart at boot time:

Step 2: Install Spreed WebRTC Server on Ubuntu Using Docker Image

Once you have Docker installed, run the following command to create a directory for Spreed WebRTC and download a server.conf file to that directory. This file allows you to provide customized parameters to Spreed WebRTC server when running the Docker image.

Then edit the file with a command-line text editor like Nano.

Find the following line.

Spreed needs to listen to 0.0.0.0:8080 in the Docker container, so it can receive requests from the host.

Save and close the file.

Before running the Spreed WebRTC Docker container, we need to create enough entropy for server secrets generation. we can use rng-tools to create entropy.

Once installed, run

Then issue the following command to run the spreed/webrtc docker image with your server.conf file.

Where:

  • -d: Detached mode makes the container run in the background.
  • --name: Give your Docker container a custom name.
  • -p: Publish a container’s port to the host. The first port if the host port, the second is the container’s port. Spreed also listens on port 8443 in the Docker container for HTTPS request, but we will use Apache/Nginx to terminate TLS connection, so we don’t need to pubish the 8443 port to the host.
  • -v: Create a bind mount. Docker bind mounts /etc/spreed/ in the host to /etc/spreed/ in the Docker container.
  • -t: Allocate a pseudo-TTY.
  • -c: Override the default /etc/spreed/server.conf file in the Docker container.

Now Spreed WebRTC server is listening on 127.0.0.1:8080, as can be seen with:

Step 3: Set up Reverse Proxy

To access the Spreed web interface via a domain name, we need to set up a reverse proxy for it using Apache or Nginx. It will also allow you to enable HTTPS, so the connection can be encrypted.

Apache

Install Apache web server on Ubuntu.

Then create a virtual host file for Spreed.

Put the following text into the file. Replace spreed.example.com with your preferred hostname and don’t forget to set a DNS A record for this hostname.

Save and close the file. Then we need to enable proxy_http module.

Next, enable this virtual host.

Test configurations and reload Apache

Now you should be able to access Spreed WebRTC via http://spreed.example.com in web browser.

Docker apache php

Nginx

First, install Nginx on Ubuntu.

Then create a server block file for Spreed WebRTC.

Put the following text into the file. Replace spreed.example.com with your preferred hostname and don’t forget to set DNS A record for this hostname.

Save and close the file. Then test Nginx configurations and reload.

Now you should be able to access Spreed WebRTC via http://spreed.example.com in web browser.

Step 4: Obtain and Install TLS Certificate

Now let’s obtain a free TLS certificate from Let’s encrypt. Drivers adlink usb devices. Run the following commands to install Let’s Encrypt client (certbot) from the official certbot PPA.

If you use Apache web server, then you also need to install the Certbot Apache plugin.

Then issue the following command to obtain a free TLS/SSL certificate.

If you use Nginx web server, then you need to install the Certbot Nginx plugin.

Then use the Nginx plugin to obtain and install the certificate by running the following command.

You will see the following text indicating that you have successfully obtained a TLS certificate.

Step 5: Install a TURN/STUN Server

WebRTC won’t work if users are behind different NAT devices. It will be blocked. To traverse NAT, we need to set up a TURN/STUN server as a relay between Web browsers. TURN stands for Traversal Using Relays around NAT. Coturn is a free and open-source TURN and STUN server for VoIP and WebRTC.

Coturn is available from the Ubuntu repository, so install it with the following command:

Once it’s installed, it will be automatically started. You can check its status with:

Apache web server docker port

Sample Output:

How To Configure Apache Webserver “httpd” In Docker Container ..

If it isn’t running, then manually start it with:

And also enable auto-start at boot time:

Step 6: Configure Coturn for Spreed WebRTC

Edit the main configuration file.

By default, all lines in this file are commented out. Below is an example configuration that you can copy and paste into your file.

Ansible
  • Replace your-domain.com with the domain name for your NextCloud or Spreed WebRTC.
  • Replace 12.34.56.78 with the server public IP address.
  • Set a long and secure authenticate secret. (You can use the openssl rand -base64 20 command to generate a random string.)

BUILD AN APACHE WEB SERVER AND RUN IT AS A DOCKER CONTAINER ..

Download chiligreen driver. Save and close the file. Then restart coturn server with:

Coturn runs as the turnserver user. Run the following command and you should see it’s listening on port 8443.

Now let’s edit Spreed WebRTC configuration file.

Add the following two lines in the [app] section. Replace red-text accordingly.

Save and close the file. Then restart Spreed WebRTC docker container with

You should open TCP and UDP port 8843 in the firewall for Coturn to work. If you use the UFW firewall, run the following commands.

Once Coturn is running and Spreed WebRTC is restarted, users who are behind NAT should be able to use audio/video calls normally.

Next Step

I hope this tutorial helped you install Spreed WebRTC server on Ubuntu using the Docker image. You may also want to integrate Spreed.Me with NextCloud.

As always, if you found this post useful, then subscribe to our free newsletter.

[Total: 2 Average: 5]