Hi, everyone, and welcome back.
Now in today's video, we will be discussing about the Nginx configuration file in more detail.
And the primary aim of today's video is to go ahead and understand the basics about the context.
Now, at a high level overview, the Nginx configuration file is divided across a range of contexts,
or you can say it is divided across multiple sections.
Now each context contains its own set of directives to control a specific aspect of Nginx.
For example, let's assume that you have a Nginx configuration file and this configuration file contains
multiple contexts.
You have a main context, you have a events, you have a Http context, you have a mail context, etcetera.
And in each of these contexts there are certain directives and parameters that you can set.
So let us quickly understand it with a WhatsApp example.
So currently I have a WhatsApp web that is up and running and currently this is a settings.
So under settings you have multiple sections.
So you can also refer to as multiple contexts.
And within the specific section, let's say I go into a specific section.
Now there are multiple directives that are available or multiple options that are available and you
can go ahead and either select or deselect a specific option.
So you have a context of notification.
You have a context of theme that is available in here.
You also have multiple options that you can select and so on.
So this is what is referred to as a context and under context.
There are multiple directives.
Now taking an example of the Nginx configuration file, let's quickly open this up.
So within this configuration file, you have multiple contexts like events like Http and so on.
And within these contexts you have multiple options that are available.
All right.
So this is one important part to remember.
So within the curly braces, here are various options and the primary container here is referred to
as a context.
Great.
Now there are multiple contexts that are available, and in each context, you can have multiple set
of directives.
So you have a main context, events, context, Http, context, mail, context and so on.
And each context controls a specific area of Nginx functionality.
So let's look into the main context first.
So any directives that exist entirely outside of the context blocks is said to inhabit the main context.
So if you look into various directives that are available, they are outside of the context blocks altogether.
For example, here you see that these highlighted directives are under the Http context block.
So you have a curly braces that are starting and ending.
Similarly, you have a directive of worker underscore connection, and it is under the events context.
However, there are certain directives here that are not really present in any of the context over here.
So these are referred to as the main context.
So main context is used to configure details that affect the entire application on a basic level.
For example, you change the user to enginex.
So all of the worker processes of the Nginx application will be using this specific user.
So this is the basics of main context.
Second, you have event context.
So this basically defines on how Nginx handles connection at a general level.
For example, under events you have worker underscore connections and you have 1024.
So worker underscore connection sets the maximum number of simultaneous connections that can be opened
by a worker process.
So again, this is something that can be tuned depending upon the requirement.
And the most important context that you will be using extensively in the production environment is the
Http context.
So this context contains all the directives and other context necessary to define on how to handle a
Http or Https connections and its associated parameters.
From what I have seen in the organizations where Nginx is extensively used, 98% of the time, the Nginx
administrator will go ahead and configure this in detail based on the requirements occasionally, or
I would say on a very rare cases, they would work based on various other contexts like event, context
and others.
Great.
So this is a high level overview about the overall Nginx configuration file structure.
So with this we conclude today's video.