DEV Community

loading...
Cover image for Do you know nginx, lets talk about?

Do you know nginx, lets talk about?

enggaruny profile image Arun Yadav ・2 min read

Follow me on Twitter

What is nginx

Nginx, pronounced like “engine-ex”, is an open-source web server that, since its initial success as a web server, is now also used as a reverse proxy, HTTP cache, and load balancer.

How Does Nginx Work

Nginx is built to offer low memory usage and high concurrency. Rather than creating new processes for each web request, Nginx uses an asynchronous, event-driven approach where requests are handled in a single thread.

With Nginx, one master process can control multiple worker processes. The master maintains the worker processes, while the workers do the actual processing. Because Nginx is asynchronous, each request can be executed by the worker concurrently without blocking other requests.

Installing Node on Ubuntu

Executing the following bash commands will setup NodeJS and npm on your Ubuntu machine:

sudo apt-get update 
sudo apt-get install nodejs 
sudo apt-get install nodejs-legacy 
sudo apt-get install npm
Enter fullscreen mode Exit fullscreen mode

Installing NGINX on Ubuntu

sudo apt-get update 
sudo apt-get install nginx
Enter fullscreen mode Exit fullscreen mode

Serving Static Contents

Let’s start simple and first, we will use NGINX to serve a static website in our first demo.

Configuring NGINX

Configuration files can be found on /etc/nginx/. NGINX comes with a default site config file and we can open it using nano:

sudo nano /etc/nginx/sites-available/default
Enter fullscreen mode Exit fullscreen mode

We will not change anything in this file yet but if we do, we have to restart the NGINX server afterward to make these changes take effect.

sudo service nginx restart
Enter fullscreen mode Exit fullscreen mode

In this post, we saw how to serve static web applications using NGINX. Follow me on Twitter

Discussion (1)

pic
Editor guide
Collapse
jmdejager profile image
🐤🥇 Jasper de Jager

Use nginx for most of my projects. Love the simplicity and speed! Especially their docker container is out of the box awesomeness 😎🙂