WEBVTT

00:00.110 --> 00:01.600
Hi, everyone, and welcome back.

00:01.610 --> 00:06.950
Now in today's video, we will be discussing about the Nginx configuration file in more detail.

00:06.950 --> 00:12.860
And the primary aim of today's video is to go ahead and understand the basics about the context.

00:12.980 --> 00:19.130
Now, at a high level overview, the Nginx configuration file is divided across a range of contexts,

00:19.130 --> 00:22.610
or you can say it is divided across multiple sections.

00:22.610 --> 00:29.210
Now each context contains its own set of directives to control a specific aspect of Nginx.

00:29.210 --> 00:35.690
For example, let's assume that you have a Nginx configuration file and this configuration file contains

00:35.690 --> 00:36.980
multiple contexts.

00:36.980 --> 00:43.070
You have a main context, you have a events, you have a Http context, you have a mail context, etcetera.

00:43.070 --> 00:48.740
And in each of these contexts there are certain directives and parameters that you can set.

00:48.740 --> 00:52.010
So let us quickly understand it with a WhatsApp example.

00:52.010 --> 00:56.750
So currently I have a WhatsApp web that is up and running and currently this is a settings.

00:56.750 --> 00:59.720
So under settings you have multiple sections.

00:59.720 --> 01:02.970
So you can also refer to as multiple contexts.

01:02.970 --> 01:07.410
And within the specific section, let's say I go into a specific section.

01:07.410 --> 01:13.110
Now there are multiple directives that are available or multiple options that are available and you

01:13.110 --> 01:17.280
can go ahead and either select or deselect a specific option.

01:17.280 --> 01:20.130
So you have a context of notification.

01:20.130 --> 01:23.550
You have a context of theme that is available in here.

01:23.550 --> 01:26.880
You also have multiple options that you can select and so on.

01:26.880 --> 01:30.720
So this is what is referred to as a context and under context.

01:30.720 --> 01:32.400
There are multiple directives.

01:32.400 --> 01:37.290
Now taking an example of the Nginx configuration file, let's quickly open this up.

01:37.290 --> 01:44.220
So within this configuration file, you have multiple contexts like events like Http and so on.

01:44.220 --> 01:48.900
And within these contexts you have multiple options that are available.

01:49.080 --> 01:49.470
All right.

01:49.470 --> 01:51.840
So this is one important part to remember.

01:51.840 --> 01:57.990
So within the curly braces, here are various options and the primary container here is referred to

01:57.990 --> 01:59.070
as a context.

01:59.190 --> 01:59.700
Great.

01:59.730 --> 02:04.980
Now there are multiple contexts that are available, and in each context, you can have multiple set

02:04.980 --> 02:05.940
of directives.

02:05.940 --> 02:11.700
So you have a main context, events, context, Http, context, mail, context and so on.

02:11.700 --> 02:17.010
And each context controls a specific area of Nginx functionality.

02:17.010 --> 02:19.710
So let's look into the main context first.

02:19.710 --> 02:27.780
So any directives that exist entirely outside of the context blocks is said to inhabit the main context.

02:27.780 --> 02:36.180
So if you look into various directives that are available, they are outside of the context blocks altogether.

02:36.180 --> 02:42.900
For example, here you see that these highlighted directives are under the Http context block.

02:42.900 --> 02:45.690
So you have a curly braces that are starting and ending.

02:45.690 --> 02:52.050
Similarly, you have a directive of worker underscore connection, and it is under the events context.

02:52.080 --> 02:58.770
However, there are certain directives here that are not really present in any of the context over here.

02:58.770 --> 03:01.740
So these are referred to as the main context.

03:01.740 --> 03:08.940
So main context is used to configure details that affect the entire application on a basic level.

03:08.940 --> 03:11.730
For example, you change the user to enginex.

03:11.730 --> 03:17.580
So all of the worker processes of the Nginx application will be using this specific user.

03:17.580 --> 03:20.340
So this is the basics of main context.

03:20.340 --> 03:22.620
Second, you have event context.

03:22.620 --> 03:28.110
So this basically defines on how Nginx handles connection at a general level.

03:28.110 --> 03:34.350
For example, under events you have worker underscore connections and you have 1024.

03:34.350 --> 03:40.230
So worker underscore connection sets the maximum number of simultaneous connections that can be opened

03:40.230 --> 03:41.760
by a worker process.

03:41.760 --> 03:46.050
So again, this is something that can be tuned depending upon the requirement.

03:46.050 --> 03:52.560
And the most important context that you will be using extensively in the production environment is the

03:52.560 --> 03:53.820
Http context.

03:53.820 --> 04:01.280
So this context contains all the directives and other context necessary to define on how to handle a

04:01.290 --> 04:05.490
Http or Https connections and its associated parameters.

04:05.490 --> 04:13.740
From what I have seen in the organizations where Nginx is extensively used, 98% of the time, the Nginx

04:13.740 --> 04:20.970
administrator will go ahead and configure this in detail based on the requirements occasionally, or

04:20.970 --> 04:27.330
I would say on a very rare cases, they would work based on various other contexts like event, context

04:27.330 --> 04:28.380
and others.

04:28.530 --> 04:29.130
Great.

04:29.130 --> 04:34.800
So this is a high level overview about the overall Nginx configuration file structure.

04:34.800 --> 04:37.410
So with this we conclude today's video.
