Part 1 - NGINX Web Server ( Installation & Configuration )

Techbeast.org
11 Oct 202023:19

Summary

TLDRThis video script from techbeats.org introduces viewers to Nginx, an open-source web server known for its user-friendly configuration and advanced features. It offers a three-part series starting with the installation and configuration of Nginx on an Ubuntu machine. The tutorial demonstrates how to set up Nginx to serve websites, handle PHP, and create custom web pages. It also covers reverse proxy, load balancing, and mail proxy functionalities. The script guides through editing configuration files, creating custom error pages, and enhancing the server's performance with static content delivery.

Takeaways

  • πŸ˜€ Nginx is an open-source web server known for its user-friendly configuration files and advanced features, which has gained popularity in various industries.
  • 🌐 The video is a part of a three-part series focusing on the installation and configuration of Nginx, including serving websites and running PHP.
  • πŸ” Nginx can function as an HTTP server, reverse proxy server, load balancer, mail proxy server, and HTTP cache.
  • πŸš€ Compared to Apache, Nginx handles concurrent clients and web traffic more efficiently, making it a preferred choice for many web servers worldwide.
  • πŸ“ˆ The open-source version of Nginx is available for use, and it is known for serving static content faster and having a highly scalable architecture with a single-thread handling multiple connections.
  • πŸ› οΈ The tutorial demonstrates installing Nginx on an Ubuntu machine using the apt-get package manager and checking its status with systemctl.
  • πŸ“ The script explains how to configure Nginx by editing the 'nginx.conf' file and creating custom server blocks in the 'sites-available' and 'sites-enabled' directories.
  • 🌐 It shows how to create a custom welcome page for a website using Nginx by editing HTML files and configuring the server to serve these files instead of the default page.
  • πŸ”— The video covers how to set up custom error pages in Nginx, providing a more user-friendly experience when content is not found or server errors occur.
  • πŸ›‘οΈ The next part of the video series will cover securing websites with Nginx, including using self-signed certificates and IP whitelisting for enhanced security.
  • πŸ“š The script encourages viewers to subscribe to the channel for more educational content on technology and web development.

Q & A

  • What is Nginx and why is it gaining popularity?

    -Nginx is an open-source web server known for its user-friendly configuration files and advanced features. It's gaining popularity due to its ability to handle concurrent clients and web traffic more efficiently than Apache, as well as its highly scalable architecture.

  • What are the main functions of Nginx?

    -Nginx can function as an HTTP server, a reverse proxy server, a load balancer, a mail proxy server, and also handle HTTP caching.

  • How does Nginx differ from Apache in terms of performance?

    -Nginx can handle more concurrent clients and web traffic better than Apache, making it a preferred choice for high-traffic websites.

  • What is the process of installing Nginx on an Ubuntu machine?

    -Installing Nginx on Ubuntu is straightforward and can be done using the command 'sudo apt-get install nginx', which installs all necessary packages and dependencies.

  • How can you check if Nginx is installed and running on your system?

    -You can check the status of Nginx by typing 'sudo systemctl status nginx' in the terminal, which will show whether Nginx is active and running.

  • What is the default web page served by Nginx after installation?

    -The default web page served by Nginx is a 'Welcome to Nginx' page, which can be accessed by typing 'localhost' in the browser.

  • How can you create a custom configuration file for Nginx?

    -To create a custom configuration file, you need to navigate to the '/etc/nginx/conf.d' directory and create a new file with a '.conf' extension, such as 'techbeast.local.conf', and then define the server settings within this file.

  • What command can be used to test the Nginx configuration file for any syntax errors?

    -The command 'nginx -t' can be used to test the Nginx configuration file for any syntax errors.

  • How do you reload Nginx to apply configuration changes?

    -To apply configuration changes, you should reload Nginx using the command 'sudo systemctl reload nginx'.

  • Can you customize error pages in Nginx and how?

    -Yes, you can customize error pages in Nginx by specifying the location of custom error pages in the configuration file using the 'error_page' directive and linking it to the desired error page files.

  • How can you serve multiple pages with different content using Nginx?

    -You can serve multiple pages with different content by configuring different 'location' blocks within the Nginx configuration file, each serving a different file or directory as needed.

  • What is the purpose of the 'try_files' directive in Nginx configuration?

    -The 'try_files' directive in Nginx is used to specify a list of files that Nginx should attempt to serve in the order listed if the requested URI is not found.

  • How can you simulate an internal server error for testing purposes in Nginx?

    -You can simulate an internal server error by creating a custom location directive that returns a non-existent file or path, which will trigger a 500 error, and then testing the configuration with 'nginx -t' and reloading Nginx.

Outlines

00:00

🌐 Introduction to NGINX Web Server

The video script introduces the NGINX web server, an open-source alternative to Apache, known for its user-friendly configuration and advanced features. It's gaining popularity for its ability to handle concurrent clients and web traffic more efficiently. The speaker outlines a three-part series, starting with the installation and configuration of NGINX, and touches on its capabilities as an HTTP server, reverse proxy, load balancer, and mail proxy. The script also compares NGINX with Apache, highlighting its performance and scalability advantages.

05:00

πŸ› οΈ Installing and Configuring NGINX

This section of the script provides a step-by-step guide on installing NGINX on an Ubuntu machine using the apt-get package manager. It explains how to verify the installation and check the server status. The speaker demonstrates how to serve the default NGINX welcome page and suggests creating custom web pages. The explanation includes navigating to the NGINX configuration directory, understanding the default configuration file, and the process of creating a custom configuration file for a website named 'techbeast.local'.

10:02

πŸ“ Customizing NGINX Configuration

The script delves into the details of customizing the NGINX configuration file. It discusses the structure of the configuration, including the server block, listening port, index file specifications, server name, and root directory. The speaker shows how to unlink the default configuration and create a new one using a text editor. The importance of the 'conf.d' directory and 'sites-enabled' folder is highlighted, along with the process of testing the configuration for syntax errors before reloading NGINX to apply changes.

15:04

🎨 Creating Custom Web Pages for NGINX

The speaker guides the audience through creating a custom web page for their NGINX server. They start by creating a simple 'index.html' file and explain the process of updating the NGINX configuration to serve this new page. The script also covers moving additional web pages and assets from a cloned repository to the server's document root. The importance of reloading NGINX after making configuration changes is reiterated to ensure the new pages are served correctly.

20:04

πŸ”’ Configuring Error Pages and Advanced Routing

The script explains how to configure custom error pages in NGINX, such as 400 and 404 errors, by editing the configuration file to serve specific error documents. It also covers setting up advanced routing for different URL paths, ensuring that NGINX serves the correct content based on the user's request. The speaker provides an example of configuring a 'force' path to serve a 'fast.html' file and demonstrates testing the configuration with a simulated 500 error to show how NGINX serves the custom 50x error page.

πŸ›‘οΈ Securing NGINX and Future Video Content

In the final paragraph, the speaker teases the next part of the series, which will focus on securing the NGINX server. This includes using self-signed certificates for HTTPS, whitelisting IP addresses for access, and implementing other security features. The script concludes with an invitation for viewers to subscribe to the channel for more informative content on technology and web server management.

Mindmap

Keywords

πŸ’‘nginx

Nginx is an open-source web server software that is used to serve websites and handle HTTP requests. It is known for its high performance and ability to handle a large number of concurrent connections. In the video, the main theme revolves around installing and configuring Nginx, highlighting its features and benefits over other web servers like Apache.

πŸ’‘Apache web server

The Apache web server is a widely used open-source web server software that has been a dominant player in the web server market for many years. In the script, it is mentioned as a comparison to Nginx, indicating that while Apache has been traditionally used, Nginx is now gaining popularity due to its advanced features and performance.

πŸ’‘configuration files

Configuration files are used in software applications, such as web servers, to define the settings and parameters for the application's operation. In the context of the video, Nginx's user-friendly configuration files are highlighted as one of its advantages, making it easier for users to customize their web server environment.

πŸ’‘reverse proxy server

A reverse proxy server is a type of server that sits in front of one or more backend servers and forwards client requests to those backend servers. Nginx can function as a reverse proxy, which is one of its advanced features discussed in the video, allowing it to distribute incoming traffic to multiple backend servers efficiently.

πŸ’‘load balancer

A load balancer is a system that distributes network or application traffic across multiple servers to ensure no single server bears too much demand. The video explains that Nginx can act as a load balancer, which is crucial for managing traffic across multiple servers to improve responsiveness and availability.

πŸ’‘HTTP server

An HTTP server is a program that processes requests via HTTP, the foundational protocol for data communication on the World Wide Web. The script mentions that Nginx can act as an HTTP server, which is its primary function, responding to client requests and serving web content.

πŸ’‘concurrent clients

Concurrent clients refer to the number of users or client devices that can interact with a server at the same time. The video script highlights that Nginx can handle a higher number of concurrent clients more effectively than Apache, showcasing its ability to manage more traffic.

πŸ’‘scalability

Scalability is the ability of a system, network, or process to handle a growing amount of work, or its potential to be enlarged to accommodate that growth. The script mentions that Nginx has a highly scalable architecture, which means it can efficiently manage an increasing load, making it suitable for growing websites.

πŸ’‘static content

Static content refers to web content that does not change, such as HTML pages, images, and client-side scripts. In the video, it is mentioned that Nginx serves static content faster than Apache, which is beneficial for websites that primarily serve static files to users.

πŸ’‘custom web pages

Custom web pages are web pages designed and created by users to meet specific needs or preferences. The video script provides a tutorial on how to create and serve custom web pages using Nginx, demonstrating how users can use Nginx to host their own websites with personalized content.

πŸ’‘error pages

Error pages are HTML pages displayed in response to a specific type of HTTP status code, indicating that a client's request could not be met. The video script discusses how to configure custom error pages in Nginx, which can provide a better user experience by giving more informative or visually appealing responses to errors.

Highlights

Introduction to nginx as an open-source web server with user-friendly configuration files and advanced features.

Comparison of nginx with Apache, highlighting nginx's ability to handle more concurrent clients and web traffic.

Explanation of nginx's roles including HTTP server, reverse proxy server, load balancer, mail proxy server, and HTTP cache.

The three-part series structure of the video, starting with installation and configuration of nginx.

Step-by-step guide on installing nginx on an Ubuntu machine using the apt-get command.

Verification of nginx installation and its active status using systemctl.

Demonstration of accessing the default nginx welcome page through curl and a web browser.

Overview of nginx configuration files and directories, including the default configuration file nginx.conf.

Process of creating a custom nginx configuration file and unlinking the default configuration.

Configuration of server block elements such as listen port, index files, server name, and root directory.

Use of nginx -t command to test configuration file syntax and correctness.

Creating custom web pages and serving static content with nginx.

Editing the default nginx webpage to serve a custom index.html file.

Instructions on how to reload nginx to apply configuration changes.

Customization of nginx to serve multiple pages and handle URL paths.

Configuration of custom error pages in nginx for 400 and 404 errors.

Simulating and testing a 500 internal server error with a custom location block.

Setup of a custom 50x error page for internal server errors in nginx.

Teaser for the next video part focusing on securing the nginx server with SSL and IP whitelisting.

Call to action for viewers to subscribe to the channel for more tech-related content.

Transcripts

play00:00

hey guys welcome to the channel

play00:01

techbeats.org so today what we are going

play00:03

to see is all about

play00:05

nginx nginx is an open source web server

play00:07

for all your needs basically

play00:09

so today i think most of us have heard

play00:11

about apache web server which was um

play00:14

powering up a lot of websites around the

play00:15

world for for the past

play00:17

few years and now nginx is something

play00:19

like uh booming

play00:21

and due to its user friendly

play00:22

configuration files and there are some

play00:24

advanced features available

play00:26

uh nginx is now used in a lot of

play00:28

industries around the world

play00:30

okay so basically this is a three part

play00:33

series

play00:33

and this is a part one of this video and

play00:35

which is uh installation and

play00:37

configuration so where i will show you

play00:39

how to install nginx

play00:40

in your machine and how you can

play00:42

configure it how you can serve your own

play00:44

websites and how you can run php

play00:47

and all these kind of stuffs using this

play00:49

nginx web server okay

play00:51

so what nginx can do for you so

play00:53

basically it's a http server okay so

play00:55

when the client is asking something

play00:57

and the server will respond so basically

play00:59

uh

play01:00

it's pretty straightforward okay so it

play01:02

can act as a

play01:03

http server and it can act as a reverse

play01:06

proxy server so

play01:07

reverse proxy server is something like a

play01:08

server which is in front of your

play01:11

main server so instead of server

play01:12

directly sending you all the information

play01:15

it will use uh this

play01:16

reverse proxy server okay so nginx can

play01:19

act as a reverse proxy server

play01:20

and it can act as a load balancer so

play01:23

let's say if you have two or three

play01:24

servers running on and if you you can

play01:26

run nginx in front of it and nginx will

play01:29

balance all the loads uh between these

play01:31

uh two or three servers which you are

play01:33

running and it can act as a mail proxy

play01:36

server and

play01:37

it can also act as a http catch okay so

play01:39

there are a lot of

play01:40

benefits around using this nginx okay

play01:43

so next why nginx okay so

play01:46

how it is different from apache and why

play01:49

uh we should take a look at

play01:50

nginx in today's scenario so nginx can

play01:54

handle concurrent clients and more web

play01:56

traffic okay better than apache so today

play01:58

already

play01:59

uh nginx is powering up thousands of web

play02:02

servers around the world

play02:03

and a lot a lot of um uh

play02:06

industries are using this uh nginx okay

play02:09

as their web server so there are already

play02:11

open source version is available and

play02:13

also uh enterprise version is available

play02:15

so

play02:15

here uh we are just going to take a uh

play02:18

take a look at open source version of

play02:19

this engine x and we are going to set up

play02:21

everything from the scratch okay

play02:22

so it can so uh static contents faster

play02:25

than apache web server so let's say if

play02:26

you're hosting your um

play02:28

websites uh somewhere you can consider

play02:30

using nginx and which will serve files

play02:33

faster

play02:34

for the users and it has a highly

play02:36

scalable architecture

play02:37

and it's a single thread which can

play02:39

handle multiple connections okay so

play02:41

that's some of the features of nginx and

play02:44

now

play02:44

straight away i'm gonna take you to uh

play02:46

hands-on and so let's get our

play02:48

hands dirty uh by installing afresh

play02:51

nginx in your machine and how you can

play02:53

run

play02:54

or fire up your uh first web application

play02:56

okay

play02:57

yeah okay so now i'm in my ubuntu

play02:59

machine where i'm going to show you how

play03:01

to install

play03:01

nginx from the scratch okay so um when

play03:04

it comes to ubuntu it's always easy to

play03:07

install packages just by typing soda app

play03:09

dash

play03:09

get installed so in the same way

play03:11

installing nginx is also pretty

play03:13

straightforward and it is easy

play03:14

so you can just type sudo

play03:18

apt dash get install nginx okay

play03:22

so this will install all the nginx

play03:23

packages i'm just going to give uh

play03:25

s and it will install all the uh

play03:27

dependencies and the packages are needed

play03:30

for your uh to run the nginx in your

play03:33

ubuntu machine

play03:34

okay so it will take a while and you can

play03:37

see the nginx now

play03:38

uh successfully installed here so you

play03:41

can always check the status of this

play03:43

nginx whether it is successfully

play03:44

installed and it is running or not

play03:46

so just by typing sudo system ctl

play03:50

status nginx okay so this will show you

play03:53

uh whether nginx is properly installed

play03:55

and running wow that's great so it's

play03:57

active and it's running

play03:58

so now i can just make a simple curl by

play04:00

typing

play04:01

localhost okay so this will respond with

play04:04

a beautiful welcome to nginx webpage

play04:06

okay so now uh for this video i'm just

play04:09

using an aws instance machine

play04:11

so basically uh this is the public ip of

play04:14

the

play04:14

machine which i'm using for this video

play04:16

so now when i just uh reload this page

play04:19

uh you can see uh okay welcome to nginx

play04:21

my

play04:22

my nginx has been the successfully

play04:24

installed and it's serving a

play04:26

web page just by saying that uh

play04:28

everybody i'm running

play04:29

running in a good condition okay so

play04:32

so you can always uh you can always uh

play04:36

create your own custom nginx uh web

play04:38

pages and to serve your own

play04:41

static web pages or whatever you want to

play04:43

run some databases you can use

play04:45

nginx for that purpose so basically this

play04:47

is the default webpage

play04:48

served by nginx and how we can able to

play04:51

edit it and how we can

play04:52

able to run our own custom web pages

play04:54

okay so that is so important so now

play04:56

for that i am just going to run as a

play04:58

sudo su so that i don't want to use sudo

play05:00

command all the time

play05:01

so let me just go to cd slash atc

play05:04

ng next okay so this is where all your

play05:07

configuration file will

play05:09

be residing okay so slash atc slash

play05:11

nginx and this is the folder

play05:13

where all your uh files related to this

play05:15

nginx will be

play05:16

available so now uh the default

play05:19

configuration file is cat

play05:21

space nginx.conf let me show you uh

play05:25

what is available inside so basically

play05:27

nginx will

play05:28

uh create a user uh www dash data so

play05:31

this will be the default user which

play05:32

nginx will

play05:34

will make use of and it will run this

play05:36

pid all these process

play05:38

okay so if you want you can always run

play05:39

as a root user also okay

play05:41

so so now uh all the uh

play05:45

this is the basic uh http configurations

play05:48

and these are all the

play05:49

access locks and error locks file which

play05:51

you can find under where log

play05:53

nginx folder and this is uh

play05:56

something important so this is where all

play05:58

the configuration file uh the custom

play06:00

configuration file which we are going to

play06:02

create and we are going to see in this

play06:04

video will be available inside this conf

play06:06

dot

play06:06

d directory okay so and slash nginx

play06:10

slash sites

play06:10

enable so basically this two folders uh

play06:13

nginx server will look for

play06:15

available configuration files and this

play06:17

is something for the mail server

play06:19

okay so which you can make use of okay

play06:23

to send emails and all these kind of

play06:24

stuff okay so now

play06:26

let me just go to this uh

play06:30

sites dash enable folder okay change

play06:33

directory sites dash enabled and

play06:35

you can see uh there is a

play06:38

file called default which has a link

play06:41

okay so the file atc

play06:42

slash nginx slash sites available slash

play06:45

default this file is already linked uh

play06:47

to this site enabled folder okay so if

play06:50

uh we want to create our own custom

play06:53

configuration file

play06:54

we need to um unlink this and we want to

play06:56

edit uh or create our own custom

play06:58

configuration file

play06:59

so to do that what i'm going to do is

play07:01

i'm just going to unlink this

play07:02

default file okay so now when you

play07:06

check what is inside this folder there

play07:08

is nothing okay

play07:09

so now we have successfully unlinked so

play07:11

now you can just

play07:13

go to uh conf d folder

play07:16

and you can create your own

play07:17

configuration file for this okay

play07:20

so now uh let me just name this

play07:22

configuration as i'm going to create a

play07:24

uh configuration file for example a nano

play07:27

tech beast dot local

play07:30

dot conf so basically this can be

play07:33

anything so for example if you're

play07:34

running some

play07:34

example.com or some xyz.com so you can

play07:37

just

play07:38

create a configuration file under the

play07:40

name example.com.conf

play07:43

okay so so this is my configuration file

play07:46

basically so the configuration file uh

play07:49

it all starts with server okay

play07:51

so so this is a basic configuration file

play07:54

which we are going to take a look at

play07:56

uh now and so the server will always

play07:59

listen on port 80 by default and if you

play08:01

want to change

play08:02

different ports uh you're good to do it

play08:05

you're good to go and you can do it

play08:07

so listen 80 the server will listen on

play08:08

port 80 and

play08:10

we need to specify the index file okay

play08:12

so

play08:13

i'm just going to specify some index

play08:15

file formats which is index.html

play08:18

index.html and index.php

play08:22

so basically this nginx server will look

play08:25

for this index

play08:26

files in uh the order which we specify

play08:30

so index.html index.html and index.php

play08:33

it will look for the files in this order

play08:35

okay so now

play08:36

uh we can give a name for our server so

play08:39

server name

play08:40

is something like tech beast dot

play08:43

local okay so this is the server name

play08:46

and you can give

play08:48

a custom name according to your website

play08:50

which you're going to serve

play08:51

okay and finally the root directory of

play08:54

all your

play08:55

uh website contents okay the html files

play08:58

and all these files

play08:59

um we will be available uh inside a

play09:02

folder and that's that's the root

play09:04

directory so in my case i'm just going

play09:06

to

play09:06

create a folder slash var

play09:10

www slash tech beast

play09:13

dot local okay so this will be my uh

play09:17

configuration uh i mean the the root

play09:19

folder however all my

play09:21

html files will be available okay by

play09:23

default uh engine x will be available

play09:25

under slash

play09:27

www.html okay i will show you in a while

play09:30

so let me save this configuration file

play09:32

okay so

play09:34

so maybe the configuration file nginx

play09:36

has a command

play09:37

nginx dash t so this command you can

play09:41

always use

play09:41

to check whether your configuration file

play09:43

is uh correct or not

play09:45

okay in case if you have any errors um

play09:48

the system will throw error and you can

play09:50

you can rectify it so now when i type

play09:52

nginx t

play09:53

it will show uh your syntax is okay and

play09:55

the test is successful okay

play09:58

so as i said now let me show you the

play10:00

default location of this nginx so when

play10:02

you install nginx all

play10:04

your uh configuration file will be

play10:06

available under change directory slash r

play10:08

www

play10:09

html okay so under this uh directory you

play10:12

can see an index file

play10:14

so which is the which is the

play10:17

file which so which is serving this uh

play10:19

when welcome to nginx page

play10:21

okay so basically uh so now we are going

play10:24

we are not going to use this

play10:25

instead we are asking our configuration

play10:27

file to tell

play10:28

uh nginx to use a custom location okay

play10:32

so now let me just create uh the folder

play10:35

which we

play10:36

specified there so make directory

play10:39

take beast dot local so take b start

play10:42

local okay that's great

play10:43

so we have created a folder

play10:45

techbeast.local and

play10:46

let me just go to it take base.local so

play10:50

now there is nothing inside

play10:51

so uh let me just create a simple

play10:54

index.html file

play10:56

index.html file okay so

play11:00

this is a

play11:04

simple ng-nex

play11:07

web page okay just just for

play11:10

just for our testing okay so that our

play11:14

nginx and our configuration

play11:16

um is good to go okay so

play11:19

that's it so let me just save it

play11:22

and after you finish all your

play11:24

configuration changes and everything

play11:26

uh you should always reload nginx okay

play11:29

that's the best practice so that all the

play11:30

configuration changes will take effect

play11:33

so you can reload your nginx by the

play11:35

command

play11:36

system ctl reload nginx okay so this

play11:39

will reload the nginx and now

play11:41

when you navigate to your uh web server

play11:44

and when you reload you can see

play11:46

the uh your web server is serving

play11:49

content from the path which you

play11:50

specified

play11:51

your custom path so this is a simple

play11:53

nginx web page okay

play11:54

that's so great so now uh okay so this

play11:57

is this is just a text uh which is

play11:59

showing so we want something um

play12:00

beautiful and in your case you're going

play12:02

to host your websites or something else

play12:04

right

play12:05

so instead for this video uh you can

play12:08

just go to this uh

play12:09

folder which contains some beautiful

play12:11

index page and some

play12:13

uh free open source software list of

play12:14

free open so softwares and some error

play12:16

pages okay so i will show you how you

play12:18

can configure

play12:19

your own custom error pages and all

play12:21

these kind of stuffs okay

play12:22

so now uh let me just

play12:26

uh go to the

play12:29

root directory uh sorry i mean the home

play12:31

directory

play12:32

and let me just clone so git clone

play12:36

uh this repository okay so this will

play12:39

clone all the

play12:40

this will clone the complete uh

play12:42

repository inside my machine okay

play12:44

so you can see the nginx dash basics is

play12:46

available here

play12:47

so now what i'm gonna do is i'm just

play12:49

going to move uh all these uh

play12:53

so files so when you take a look at it

play12:56

what is inside this nginx basics folder

play12:58

there's a 400

play12:59

html file file not xhtml file and some

play13:02

web pages and some index pages which we

play13:04

are going to

play13:05

uh see in a while so i just want to move

play13:07

all these files inside this wire www

play13:10

tech beast.local which we created okay

play13:13

so

play13:14

uh moo dash v so

play13:18

slash home ubuntu uh

play13:21

engine x dash basics star okay slash bar

play13:25

www uh thickbeast.local

play13:28

okay okay that's great so now we are

play13:32

moved almo uh this command will move

play13:34

all the files and folder inside this uh

play13:37

tech based.local uh folder

play13:39

so change directory by www

play13:43

techbeast.local

play13:44

so now when i list you can see all the

play13:46

files already moved here and now

play13:48

if you go and reload your web page you

play13:51

can see a beautiful

play13:52

uh website a simple website welcome to

play13:55

techbeast.org

play13:56

and this is a simple welcome page

play13:57

powered by nginx so in this way you can

play14:00

serve your own website so you can host

play14:01

your own websites

play14:02

uh in a cloud environment and you can

play14:04

configure the domain name

play14:06

uh to serve the clients or some

play14:09

beautiful websites okay

play14:10

so uh okay so next step so what we are

play14:13

going to do next we are going to serve

play14:14

this is just an index page

play14:16

how i can so multiple pages based on uh

play14:19

the

play14:19

requests okay so here for example click

play14:22

for more open source projects

play14:23

when i click so it's redirect it's

play14:26

taking me to a

play14:27

path called slash foss free open source

play14:30

software

play14:31

so this path is not available because we

play14:33

did not configure this path in our nginx

play14:35

configuration file

play14:36

and that's why nginx is serving this for

play14:38

not for not found error okay

play14:41

let's go to our configuration file and

play14:44

configure this path

play14:46

change directory slash atc nginx conf

play14:49

d so this is the folder where our

play14:51

configuration file is available and

play14:54

just type nanotechbeast.local.com okay

play14:57

so what we need to do is we need to

play14:59

configure the

play15:01

location and the path of the uh for part

play15:04

of the

play15:04

url to to make nginx serve the contents

play15:07

okay

play15:07

so let me just type location okay so

play15:10

location slash

play15:11

so this will serve all the uh this is

play15:14

the default uh

play15:15

root path which will solve all the files

play15:17

for example uh i'm just configuring

play15:19

uh this location slash by default this

play15:21

slash is a root directory okay slash

play15:24

www.local okay so try files

play15:27

uh uh dollar uri

play15:31

and dollar uri slash

play15:34

dollar uri dot html and even a 400

play15:38

error page okay so basically what i'm

play15:40

doing is i'm just telling

play15:42

nginx configuration like whatever the

play15:43

request coming in this uh

play15:45

default location you just check whether

play15:47

files are available

play15:48

you you can check some other folders uh

play15:51

subparts and you can check for

play15:53

a dot html file and you can even uh

play15:56

return a 400 error page so this is the

play15:58

default uh configuration

play16:00

uh location which we need to specify and

play16:02

now

play16:03

uh for custom parts for example location

play16:06

slash

play16:07

so now we need to serve some contents

play16:09

okay so when

play16:10

when the user requests this slash force

play16:13

there should be some contents to be

play16:14

served by our nginx okay

play16:16

so let's just use the same configuration

play16:19

try

play16:19

files and dollar uri

play16:23

and you can just so uh this uh

play16:28

dot html okay that's great so this is

play16:31

the

play16:32

file which is available inside our clone

play16:35

directory which you just cloned okay

play16:37

fast.html we're just going to serve this

play16:39

uh

play16:40

file when user requests this page okay

play16:42

so let me just

play16:43

save my nginx and as i said you can

play16:45

check your configuration just by typing

play16:47

nginx

play16:48

d and my configuration is correct

play16:51

the syntax is correct and you need to

play16:53

reload it

play16:54

system ctl reload

play16:58

nginx okay so this will reload the

play17:00

engineering so now

play17:01

if i go and reload my page you can see

play17:04

my

play17:04

nginx is serving a web page with some

play17:07

beautiful contents okay first

play17:09

so these are all some list of available

play17:10

free open source softwares and

play17:12

in this way you can sew multiple uh

play17:15

pages okay so multiple pages inside your

play17:17

website for example

play17:19

a simple index page a simple about us a

play17:21

simple portfolio

play17:22

a contact us page and all these pages

play17:25

you can serve

play17:26

using this nginx okay so now

play17:29

uh let me request for some other pages

play17:32

which is not available for example

play17:34

my page so this page we did not

play17:35

configure so let me just

play17:37

load it so you can see it's a bad

play17:38

request because the pages

play17:40

uh the page which we are requesting is

play17:42

not available and

play17:44

nginx was not able to serve it okay

play17:47

so this this page error pages is

play17:49

something like a pretty old fashion

play17:51

right so if you want to create your own

play17:52

custom error pages

play17:54

how you can do it you can always

play17:57

use the nginx configuration files and

play17:59

you can edit and all these kind of

play18:01

stuffs you can do

play18:02

to serve your own custom error pages

play18:04

okay

play18:05

let me show you how so

play18:08

nanotechbeast.local.conf okay so now

play18:10

let me create a error page a custom

play18:13

error page

play18:14

okay so error page okay for example 400

play18:18

and 404

play18:19

error slash 400.html

play18:22

okay so this is the error page which i'm

play18:25

gonna so

play18:26

so for that i'm going to going to still

play18:29

location just specify the location

play18:31

slash 400.html

play18:34

and i'm asking nginx to serve this

play18:38

uh file internally okay

play18:41

so meaning uh whenever uh a page which

play18:44

you request is not available nginx will

play18:46

forward the request internally okay

play18:49

internally

play18:49

to serve this 400.html file okay

play18:52

so that's great so now let me just save

play18:56

it

play18:57

okay so let me check the configuration

play18:59

file and the configuration file is okay

play19:01

and system ctl reload nginx

play19:05

okay so this will reload the nginx and

play19:07

now

play19:08

let's just reload this page wow that's

play19:10

great you can see

play19:11

a custom beautiful uh 400 error page

play19:14

which we just configured nginx will so

play19:16

you can search for uh all the files

play19:18

which is files and location which is not

play19:20

available for example

play19:22

uh tech beast there is no such

play19:25

uh path so page not phone sorry

play19:28

this is a simple for not x page powered

play19:30

by nginx okay

play19:32

so this is something uh which is related

play19:34

to uh

play19:36

the request which is not available and

play19:38

cannot be able to serve with the server

play19:40

so in case uh there is any issue with

play19:42

server the server will always

play19:43

respond with uh some something like 50x

play19:46

series so

play19:47

in your day-to-day life if you're using

play19:49

browsers a lot you should have came

play19:50

across all these four not x error and

play19:52

finotex error terms okay

play19:54

so find it is something like internal

play19:55

server error and which is related to

play19:57

server

play19:57

so how you can serve such uh 50x errors

play20:00

okay

play20:01

so let me uh go to the configuration

play20:04

file

play20:04

nanotech

play20:09

so what i'm going to do is i'm just

play20:10

going to copy the same error page

play20:13

configuration

play20:14

and just going to paste it okay so

play20:16

instead of

play20:18

400 i'm just going to replace it with

play20:20

500

play20:21

502 503 504

play20:27

and and it will serve

play20:30

the 50x.html file

play20:34

fi o x dot html okay same so we are just

play20:37

asking nginx to

play20:38

forward it uh internally okay so now let

play20:42

me save the configuration file

play20:45

okay sorry before that how we can test

play20:47

our how we can simulate this 500

play20:50

uh internal server error okay so then

play20:52

only we can test

play20:53

whether our whether the configuration is

play20:55

working fine or not

play20:56

okay so so for that what you can do is

play21:00

you can just create a

play21:02

custom location uh yellow custom

play21:05

path which is for 500 error okay

play21:08

so 500 error so what you can do is

play21:12

you can just create a error

play21:16

you can just simulate error by using the

play21:17

command fast cga

play21:19

underscore pass and you can just specify

play21:22

this is this is

play21:26

error this is something some random path

play21:29

so

play21:29

normally this slash this lashes is not

play21:32

available okay i'm just

play21:33

simulating a internal server error using

play21:35

this command okay

play21:36

so so now i'm just checking whether

play21:39

everything is correct or not so you

play21:41

should

play21:41

make sure that you you always keep the

play21:43

semicolon at the end of

play21:45

uh each and every line okay so now

play21:48

let me just save it okay and

play21:51

i'm just going to check my configuration

play21:53

file nginx

play21:54

t okay that's great my configuration

play21:56

file looks okay

play21:58

and i'm going to system ctl reload

play22:01

nginx i'm just going to reload it okay

play22:04

so now when i just navigate to 500

play22:08

error you can see what there seems some

play22:11

server error

play22:12

this is a simple 50x page powered by

play22:14

nginx okay

play22:15

so in this way you can serve your uh

play22:18

websites in a in a meaningful way okay

play22:21

so different parts you can sell

play22:22

different contents

play22:23

in case there is an issue with some

play22:25

pages not found you can serve a for not

play22:27

for error page

play22:28

and if there is some internal server

play22:30

error you can save server

play22:31

50x pages okay so that is pretty simple

play22:35

and you can always use nginx

play22:37

configuration files to achieve all these

play22:39

kind of stuffs

play22:40

so thanks for watching guys uh in the

play22:42

next part of this video i will show you

play22:44

how you can secure the same website okay

play22:46

so

play22:47

created uh by us just now in this part

play22:49

one of the video and how you can

play22:51

use your self-signed certificate to

play22:52

serve content securely

play22:54

and how you can whitelist the ip

play22:56

addresses where you can

play22:58

access your server from and block all

play22:59

the other sources

play23:01

sources and some security features we

play23:03

will take a look at it okay

play23:05

so thanks for watching guys subscribe to

play23:06

the channel uh if you feel

play23:08

uh the channel is really useful for your

play23:10

career or while building some

play23:12

fun projects uh feel free to subscribe

play23:14

and share your comments and let's make

play23:16

technology easy pc for everyone

play23:18

thanks for watching

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
NGINX Web ServerInstallation GuideWeb ConfigurationReverse ProxyLoad BalancerOpen SourceWeb TrafficConcurrent ClientsScalabilityTech TutorialCustom Web Pages