Background: It’s easy to pull down an existing docker image from https://hub.docker.com/ that has NGINX pre-configured. This article is for those who wish to build their own Nginx docker image. This is the best way to avoid security flaws or running an outdated version of Nginx and the OS. A prime example of this is this docker image that I almost downloaded https://hub.docker.com/r/richarvey/nginx-php-fpm . It hasn’t been updated since 2020.
NGINX is a lightweight web server that can be used for web 3 applications and other applications or websites. So learning how to install and configure Nginx is a great start for anyone new to web 3 development. This will not go into detail about how to install Docker or how to write up a Dockerfile. This will be a two part series which includes installing Nginx, serving some basic content ,installing PHP , and if I can find the time. I will touch on some JavaScript configuration.
Prerequisites: Some basic knowledge of Linux ,vim and Docker containers
OS USED: CentOS Linux release 8.4.2105
Author : Expire0 for https://Expire0.dev
Build out the base image
Defined yum variables
Add the following lines to nginx.repo.
[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/mainline/$osname/$release/$basearch/
gpgcheck=0
enabled=1
run dnf to sync up the new repo
curl -I 127.0.0.1
Output
HTTP/1.1 200 OK
Server: nginx/1.14.1
If you run “docker images”, you will now see your newly created docker image with Nginx installed. The next part We’ll focus on configuring Nginx ,installing PHP and JS. Thanks for reading and stay tune for the next part.