Hey, everyone.
And welcome back.
In today's video, we will be discussing about the modular architecture of Enginex.
Now, modular architecture basically refers to the design of any system composed of separate components
that can be connected to each other.
So this can be better explained with this diagram over here.
So generally nowadays, whenever a car manufacturing happens, there are multiple components which are
manufactured independently and only during the final process.
All of them are connected with each other and tested.
Now, this is a great way of design and it also helps.
So let's say if there is a defect in one component, you can easily disassemble everything, remove
that component and replace it with the brand new one.
So this is the right approach of doing things.
I still remember one of the persons that I know, so he had a car and there was some issue with one
of the components in that car.
So he went to a garage and the garage said that in order to remove that one component, he will have
to replace four other components.
So everything was ticked together.
It was not modular and he had to pay a good amount of price for that.
So this is the reason why nowadays even car manufacturers, their architectures are quite modular.
So in the longer term, if one of the component fails, you can easily replace that component without
touching any other one.
So this kind of a design not only is applicable to the manufacturing industry, but also to the software
industry.
And if you talk about various new applications, the operating systems, everything is built out of
modular architecture.
Now, speaking about modular architecture, definitely Enginex is also built out of modular architecture.
So in fact Nginx is in fact a collection of multiple modules.
Now, since it is a modular architecture, we can extend the functionality of Enginex by readily adding
various third party modules.
So this can be better understood with the diagram here where you have a enginex here.
So this is a enginex binary.
It consists of certain core modules which are required for the web server itself to function.
Now apart from this core modules, you can add various other modules as well.
So let's say you have a Geoip module, so you can go ahead and add a Geoip module.
You have a web application firewall module, you add it, you have a video streaming module, you add
it, and together you can have a single nginx binary, which not only contains core module, but it
also contains various third party modules.
So in case, let's say as a user, I want certain additional functionality in Nginx, what I'll do,
I'll create my own new module and I'll add that module to Nginx and boom, I have a Nginx with my own
custom functionality and this is a great approach and it provides Nginx a great capability.
So let's do one thing.
Let me quickly show you on how exactly it might look like.
So if I do a nginx hyphen v you will see that there are a lot of subset of options.
One of them are basically the modules that this nginx binary has been compiled with.
So if you see over here there are a lot of modules.
One is the Http gzip module.
Then you have the Http random index module, you have the secure link module, you also have the stream
SSL module and etcetera.
So this specific nginx binary that we are running.
So this nginx binary contains all of these modules.
So it contains multiple modules and in case if you have your own module you can go ahead and add your
module as well.
So this is one way.
Now in fact this is just an example of Nginx Now when you talk about Apache, so let's go to the Httpd.
So I have Apache installed.
Now if you go into the modules directory here and if you do ls hyphen L, you will see that there are
a lot of modules here, even Apache works based on the modular architecture.
So all of these things that you see, these are the modules of Apache.
All right, So it's not that just Nginx is doing it, even Apache is doing that.
And even if you do an LS mod, you see all of these are the modules of the Linux subsystem.
So if you go a bit down, you see this is the module name and all of these are module which Linux kernel
is been using.
So if you want to add a new module in Linux, you can easily do that.
If you want to remove a module in Linux, you can easily do that.
So this is one of the approaches of designing.
The software applications.
Now, whenever you plan to add modules, there are two important concepts that you need to remember.
First is the static modules.
Second is the dynamic modules.
So let's go ahead and understand both of them.
So static modules are compiled into your Nginx server binary at compile time.
So what happens here?
Let's say you have a nginx binary over here.
So this binary has two modules.
So you have the GZip module and you have the MP4 module.
So this is a pre-packaged binary.
So advantage of this is you have a single package, it is portable and it will work out of the box.
So if I just take this binary and put it in a different server and I install, then I will have nginx
running with both of these modules.
All right, so this modules are part of the package.
Now the problem with static modules are that it can create issue in a longer time.
If you have a lot of static modules.
So let's say that I have two static modules within my Nginx binary.
Now there is a issue with the GZip module due to which a lot of things are not working.
So if I want to remove this module altogether to just troubleshoot whether my nginx works well without
this module, I cannot do that because this module is part of the binary.
All right, so then it becomes a little difficult to troubleshoot because everything is part of the
binary here.
Now you also have dynamic modules.
So dynamic modules are something that we can create or we can even directly download the module files.
And now what we do is we reference the path of the dynamic module with the load module directive within
the Nginx configuration.
So now let's say that this is the Nginx configuration here and we have two modules here.
So these two modules are dynamic.
One, they are not built inside the nginx binary.
All right, so now what we do is if we let's say if I want to use this GZip module, so within my Nginx
configuration file, I'll say load underscore module, I'll say GZip.
This is just an example.
All right, So now you will have the GZip module at runtime.
So I want to use MP4 module.
I'll say load underscore module mp4 and we'll have the mp4 module.
So during the longer term, let's say that you are seeing a lot of issues and you suspect that it is
because of the GZip module.
What you do, you just remove this line and reload your nginx and that's about it.
Your module is no longer being used.
So dynamic modules provides a lot of advantages in the Nginx architecture.
Now before we conclude, let me quickly show you one thing.
So within the Nginx official website you have the page of Nginx third party modules.
So currently you see there are a lot of modules of third party which are available and many of them
are very important which you can use.
So Nginx by itself does not come with a huge amount of functionality.
The major important part of the functionality typically comes with the help of a third party modules.
So you can directly, let's say that you want to make use of a Http digest authentication or a Pam authentication.
So you just get the Pam module.
Either you can do a static compile, you can do a dynamic compile depending upon the use case, and
then you can have your Nginx which supports the Pam based authentication.
So similarly you have a lot of modules which you can use out of the box.
So that's the high level overview about the modular architecture of Nginx.
Again, in the upcoming videos, we'll look into how exactly we can do both static compilation of modules
as well as reference to dynamic modules within our Nginx.
So the upcoming videos would prove to be quite interesting.
So that's about it for today's video.
I hope this video has been informative for you and look forward to see you in the next video.