NGINX Tutorial - What is Nginx

158.78k views2309 WordsCopy TextShare
TechWorld with Nana
Learn what is Nginx, why do we need it, Nginx Use Cases as web server, reverse proxy and load balanc...
Video Transcript:
by the end of this video you will know not only what enginex is but also why it was created and what it's used for with real life examples back in the day when the web was still simple with less users the basic use case was a browser requested a web page from one web server the web server was a server machine that had a software installed on it that assembled the page and sent it back to the browser which then displayed it to the user a piece of software that runs on a server machine and
can respond to requests from a browser and that web server software that was enginex a piece of software that runs on a server machine and can respond to requests from a browser then web became popular so you had thousands or millions of requests per website imagine one single server handling millions of requests that's way over the technical limit of a server software well we need a few more servers to handle that load so we added 10 enginex web servers but now we need something that determines where requests from the browser and which one of those
10 servers will handle them and that's where load balancing comes in so the same engine X web server becomes a load balancer that proxies the requests to those 10 web servers and by the way the word proxy means to do something on someone else's behalf so it accepts the browser requests on behalf of the web servers so it sits at the entry like a concierge and then distributes the load among the web servers now how does it distribute the load that depends on whichever algorithm was configured on it it could be a simple logic such
as just whichever server is least busy gets the request or it could be round robin which is a popular algorithm that basically distributes the requests equally in a cyclical manner so very simple load balancing logic so now we have engine X as web server software and the proxy as well and that load balancing is just one of the functionalities of enginex proxy so it's the same server and Technology but with a different task now so what are those other features or functionalities of a proxy imagine new New York Times article comes out and millions of
people open it on their laptops in the browser now imagine every time the request lended with one of the web servers that assembled the response like put the images together get them from a database put text and paragraphs and everything together edit all the links sent it back as a response and this happened million times pretty inefficient right instead it makes sense to assemble this article get all the data from a database put the text and links and everything together once and store it it's a static article it's not going to change right so just
keep one final copy and send it to everyone who requests it that's caching functionality and it is another main feature of engine X proxy server so you can configure caching on engine X proxy so you don't have to hit the database or the web servers every time a request comes in it will just return that cached file now imagine we have hundred 100 servers of an online banking application or a social network like Facebook that makes those servers a pretty juicy Target for hackers they all want to hack into your servers and get the treasure
which is payment data personal data passwords and so on now imagine you exposed all 100 servers to Public Access so basically all those requests can directly hit each of the web servers if you do that you actually make work for hackers so much easier they would need to find just one issue in one of those 100 servers and they could potentially break into your entire system because all your servers are publicly accessible directly they can just ping the hell out of them and probe them until they find an issue or an entry because you forgot
to update a library or a software package and they can hack your web server application so you have to worry about absolutely perfectly securing 100 servers now in instead we just give them one server that is the only one that's publicly accessible you can put all your Titus security efforts on one server instead of 100 servers and this way having one entry point which is the proxy is publicly accessible entry point reduces the security attack surface tremendously and basically acts like a shield or security layer before all those web servers so in addition addtion to
load balancing and caching a very very important functionality of a proxy is an eded security for your web servers now talking about security I mentioned that since we have one entry point we can focus all our efforts to securing that one proxy server in all aspects and one important security measure is encrypted communication so front end will send encrypted message to the proxy which means even if an attacker sees that traffic on users browser or during the transmission they can't read it only the proxy server can decrypt it but again for edit Security in many
systems proxy that act as The Shield a security Shield will simply pass on that encrypted message to the web servers and the web server will decrypt it itself which is actually a better security practice so here the functionality of a proxy is to be able to accept encrypted traffic with s SL encryption so you can configure your proxy to deny any request that is not encrypted and only accept encrypted requests now imagine Netflix which by the way uses engine X in its backend and as we know Netflix has millions of users so it's getting millions
of requests for videos on its web servers and let's say it's an evening in New York millions of people come home after work all at the same time they switch on Netflix and start watching the most popular series at that time that means Suddenly at the very same time millions of requests for a highquality video is sent to Netflix so in this case imagine that engine X proxy server would have to send back the entire highquality video to millions of users at once that's a lot of bandwidth imagine how long it would take to send
it over the internet cables all the way to the TVs of millions of viewers that's where compression helps engine X proxy can also be configured to compress large images or video files to save bandwidth both on the side of the clients so people who are receiving those large files but also on the server side who is sending all that content so it arrives faster and uses up less of your internet bandwidth and as part of it it also supports sending responses in chunks instead of the entire file at once so basically it sends you part
of the video and then by the time you have watched the first half the second half of the video has been sent over to you as well so these are all the functionalities that you can configure for enginex as a proxy server now you may be thinking how do you make enginex do all these things how do you configure them how do you tell enginex whether it should act as a web server or a proxy server and how do you configure all these caching and SSL traffic and all this stuff well that's where enginex configuration
file comes in which lets you define all this configuration with so-called directives this is where you can define whether you want your engine X to be a web server or a proxy server simply by configuring whether it should forward the traffic to other web servers or whether it should handle it itself you can configure which Port you want engine X server to listen on this is an example of a simple web server configuration that listens on Port 80 and with location basically defines from where in the file system it should serve those static files back
to the browser but as we learned communicating on Port 8 or HTTP Port is insecure instead we want to encrypt all the communication and you can configure that easily in engine X to Route any traffic coming on Port 80 to https by sending L those requests to https and point and here we have an https server configured that serves the files as well as specifies the SSL certificate location the public key and the private key for the SSL communication and it listens on the https Port 443 so that's a simple configuration that allows you to
twe enginex to handle requests like that you also have its own configuration to configure load balance to multiple backend servers and within that configuration you can also Define which load balancing algorithm to use like select the least busy server or use the default one which is R Robin which as I said just equally distributes the load in a cyclical order between those servers you also have the caching configuration with multiple different elements like how long the cache should be stored before it's refreshed and so on and as you see the configuration of all these functionalities
is pretty straightforward and it's also pretty granular like you can do tons of different configuration with engine X and you actually have a full list of all those configuration blocks and directives in this list here which is a pretty huge list and as you see the configurations for proxy functionalities have proxy prefix so you can differentiate them as well now engine X is very flexible as you see and super fast as well so it became very popular in containers as well and made its way as one of the most popular solutions for kubernetes Ingress controller
functionality Ingress controller is essentially a proxy with Advanced load balancing functionality but for kubernetes so what engine X was doing for simple web servers it's now doing for kubernetes cluster in the form of Ingress controller acting as a proxy and load balancer that receives the incoming traffic first and then based on the configuration that we Define forwards it to the right service inside the cluster now this load balancing configuration as well as logic is more advanced and more kubernetes specific but the idea is pretty much the same and I actually have full videos on Ingress
and Ingress controller and how to configure it you can watch on my channel in fact I create these tutorials regularly on lot of interesting Technologies so if you want to educate yourself in tech make sure to subscribe and activate notification to get those new tutorial videos now there are actually many ingis controller implementations out there for kubernetes but enginex is one of the most popular ones and I have actually used engine X Engish controller in most of my projects as well now some of you may be thinking doesn't each Cloud platform have its own load
balancer why do I need engine X as a load balancer well you actually need both engine X Ingress controller which acts as a load balcer is used inside the cluster so unlike the proxy for web servers it's not publicly accessible so you can't access the engine X Engish controller directly from the browser it actually leaves inside the cluster Network and forwards the requests internally so who is getting the requests from public what is the public entry point for the browser requests that's the cloud load balancer like awsb for example which then forwards that request to
the ingis controller inside the cluster and this is important because it adds a very important security layer to those requests so the cluster component is never directly exposed to Public Access instead every request comes from the cloudload balancer which then forwards it to the ing controller within the cluster which then routes that traffic based on intelligent logic to different applications within the cluster and with intelligent routing what I mean is if you have one large application with lots of sub segments or microservices for example you can configure your Engish controller so if the request URL
includes online card it routes the traffic to online card microservice if it includes payment it routes the traffic to payment service and so on now some of you who've been in it for little longer may have worked with Apache web server so what's the difference between Apache web server and enginex web server well not much actually enginex and Apache web servers do pretty much the same thing just like enginex Apachi also used to be a basic web server and then they extended its functionality as a proxy and it has all these benefits and functionalities of
a proxy that we discussed Apachi was actually already widely used used when enginex was created and the major benefit of enginex was that it was faster more lightweight and definitely had an advantage when it came to serving huge amounts of static files plus as you saw it has a pretty easy configuration as well and engine X also became more popular in the container world now I hope you got a clear overview of what enginex is and hope I've answered all the questions you may have had while learning about enginex and with that thank thank you
for watching and see you in the next video
Copyright © 2024. Made with ♥ in London by YTScribe.com