Docker Apache Web Server



Docker image for Apache Web Server. Make a new Dockerfile that extends from this image: FROM sismics/apache2:latest Add your documents to the web root: RUN rm -fr /var/www/html/. ADD www /var/www/html Start a container: docker run -d -h apache2 -name apache2 -p 80:80 -restart=always sismics/apache2. Similarly, even simple HTML/CSS/JavaScript-based websites can be containerized using an Apache web server as your base image. Play around with it a bit! Once you get the hang of “Dockerizing” your web projects, they’ll be that much easier to deploy to your VPS or share with others on GitHub or the Docker Registry.

Docker Apache Web Server

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

Apache docker file

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.

Docker Training 22/29: Apache Web Server And PHP Docker Image (Dockerfile)

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.

Apache web server docker file

Next, enable this virtual host.

Docker Apache Web Server

Test configurations and reload Apache

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

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. 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:

Docker Apache Web Server

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

Sample Output:

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.

  • 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.)

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.

Docker Apache Web Server Free

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

Docker Apache Web Server Software

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.

Monitoring Apache Web Server Running On Docker

[Total: 2 Average: 5]