Nginx Ubuntu Docker

In this post, I am putting a Nginx docker in front of Ubuntu Desktop Docker as a reverse proxy. Also I deployed CertBot to issue a Let's Encrypt certificate for Ubuntu Desktop Docker's domain name. In this way, I can use my own sub-domain name on port 443, rather than 6080, to access my Ubuntu Desktop docker. Much easy and more professional way. How to Deploy NGINX Reverse Proxy in Docker on Ubuntu 20.04. June 21, 2021 June 21, 2021 by Hitesh Jethva (261 posts) under Dedicated Server Hosting, Tutorials.

Installing Docker

If you've heard about Docker, you may know about its ability to help you build applications in a sealed environment. This is helpful, as it eliminates any changes that may occur between your developer machine and your production machine, such as a VPS server from Hostwinds.

How To Install Docker

Install docker using this command:

Container technology is beneficial in sealing an environment, but when you need to configure things like SSL or other applications, this can introduce additional complexity.

Installing Nginx

Nginx (Pronounced 'Engine-ex') is a highly configurable web server. This makes it great for things setting up what's called a 'reverse proxy,' which simply means that this webserver will take in requests and forward them to our Docker containers. Add this into your Hostwinds VPS with:

Ubuntu

Setting up a simple Apache Container

For this, We're going to use the official Apache image on the Docker hub. It's documentation can be found here.

As the documentation mentions, we will need to create a DockerFile.

Using a text editor, such as nano (nano apache. docker), write a file with these contents:

Ubuntu

Now create a file called index.html, and insert this into its contents:

It is possible to use any static page or even a directory in place of the index file. For simplicity, a single HTML file is fine. Once the file is written, run these commands to build the docker file.

Visiting your server at [yourdomain:8080] or [your IP]:8080 Should result in seeing this page in your web browser

Configuring Nginx as a reverse proxy

Nginx

Docker Create Ubuntu Container

Docker

With the docker container set up to serve your files, we can set up Nginx. This way, we can mostly leave the container's configuration alone and silo it off behind Nginx. Edit /etc/nginx/nginx.conf and add in this code:

Ubuntu Docker Nginx Php

Docker

Nginx Docker Ubuntu 18.04

From here, NGINX takes in all the public requests, and the Apache container serves your files.