Introduction
Nginx is a web server. what then is a webserver? A web server is a server that hosts an application that listens to the HTTP requests .There are a few web servers around, three dominate: Apache , Microsoft InternetInformation Services (IIS) , and Nginx combined have captured around 85 percent of the market.
Why use Nginx
- it is fast
- it can accelerate your application
- it has a straight forward load Balancer
- it Scales well
Pre-requisite
Before you begin this guide, you should have a regular, non-root user with sudo privileges configured on your server.
Step 1 : Install Nginx
Since this is our first interaction with the apt packaging system in this session, we will update our local package index. Afterwards, we can install nginx: Run the following commands
$ sudo apt-get update
$ sudo apt-get install nginx
Step 2 Adjust the firewall
Nginx registers itself as a service with ufw, our firewall, upon installation. We can list the applications configurations that ufw knows how to work with by typing:
$ sudo ufw app list
you should get output like :
Available Application
Nginx FULL
Nginx HTTP
Nginx HTTP
OpenSSH
As you can see, there are three profiles available for Nginx
Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
You can enable this by typing:
$ sudo ufw allow ‘Nginx HTTP’
You can verify the change by typing
$ sudo ufw status
You should see HTTP traffic allowed in the displayed output
Status: active
To Action From OpenSSH ALLOW Anywhere Nginx HTTP ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere(v6) Nginx HTTP (v6) ALLOW Anywhere(v6)
Step 3 Check your webserver
check the status of your webserver
$ service nginx status
When you have your server’s IP address or domain, enter it into your browser’s address bar: http://server_domain_or_IP
.