Learning Library

← Back to Library

Apache & NGINX: Layer‑7 Reverse Proxies

Key Points

  • Apache and NGINX are free, open‑source HTTP servers that are also commonly used as reverse‑proxy/load‑balancer front‑ends for web applications.
  • Modern high‑traffic sites typically place multiple identical web servers behind a front‑end load balancer, which distributes incoming requests to avoid overloading any single server.
  • Load balancers can operate at Layer 4 (transport level, handling generic TCP/UDP traffic) or at Layer 7 (application level, inspecting HTTP requests), and Apache/NGINX are often used as Layer 7 balancers.
  • Using a reverse proxy provides key benefits: it enables effective load distribution across servers and hides the internal server architecture from the public, enhancing security.
  • A reverse proxy can also cache static resources (e.g., frequently used images), reducing upstream server load and speeding up response times for repeat requests.

Full Transcript

# Apache & NGINX: Layer‑7 Reverse Proxies **Source:** [https://www.youtube.com/watch?v=9nyiY-psbMs](https://www.youtube.com/watch?v=9nyiY-psbMs) **Duration:** 00:07:49 ## Summary - Apache and NGINX are free, open‑source HTTP servers that are also commonly used as reverse‑proxy/load‑balancer front‑ends for web applications. - Modern high‑traffic sites typically place multiple identical web servers behind a front‑end load balancer, which distributes incoming requests to avoid overloading any single server. - Load balancers can operate at Layer 4 (transport level, handling generic TCP/UDP traffic) or at Layer 7 (application level, inspecting HTTP requests), and Apache/NGINX are often used as Layer 7 balancers. - Using a reverse proxy provides key benefits: it enables effective load distribution across servers and hides the internal server architecture from the public, enhancing security. - A reverse proxy can also cache static resources (e.g., frequently used images), reducing upstream server load and speeding up response times for repeat requests. ## Sections - [00:00:00](https://www.youtube.com/watch?v=9nyiY-psbMs&t=0s) **Understanding Web Servers & Load Balancing** - The speaker explains how Apache/NGINX serve HTTP requests, the role of web servers, and how load balancers (including layer‑4) distribute traffic among multiple servers. - [00:03:09](https://www.youtube.com/watch?v=9nyiY-psbMs&t=189s) **Reverse Proxy Features Overview** - The speaker describes how a reverse proxy hides backend servers while providing caching, client‑side compression, and SSL termination, noting that both Apache and NGINX implement these functions. - [00:06:17](https://www.youtube.com/watch?v=9nyiY-psbMs&t=377s) **Apache vs NGINX: Dynamic Content** - The speaker compares Apache’s extensibility for dynamic HTTP content and REST calls with NGINX’s container‑focused popularity, noting they can be combined and that the best choice depends on the specific environment. ## Full Transcript
0:00If you're trying to make sense of web application architecture, you've no doubt heard of Apache and NGINX. 0:06They're both free open source projects, very commonly used as HTTP and reverse proxy servers. 0:13Let's unpack those definitions a little bit. 0:17Say I'm sitting at home with a web browser going to my favorite website, ibm.com, of course! 0:24It's easy to imagine that my browser is talking to the IBM server and asking for the right web page. 0:35That's the request right there. 0:38Now, in this case, let's say it's asking for cloud security. 0:41And the web server goes around and digs through its data to put that page together and then ships it back to me. 0:49So here's the the resulting web page nicely rendered in my browser so I can learn all about hybrid multi-cloud security solutions. 1:00A perfect afternoon activity. 1:03Now, this is an example of a simple web server--software which can accept HTTP connections 1:09and map them to documents or images or other resources and then return them to the requester. 1:15That's me, or at least my web browser. 1:18And this may have been an accurate diagram back in the early 2000s, 1:22but most public-facing websites get so much traffic that it makes sense to have a couple of web servers back here serving that content. 1:35And they're all capable of delivering the same content. 1:38And then this thing becomes a load balancer upfront to make sure that no one server gets too busy. 1:47Some load balancers operate as layer 4 load balancers, 1:51and that means that they work at the transport level, and they simply route the request to each available server. 2:00So they can handle DNS, mail, TCP and UDP traffic. 2:04Now, I personally like my load balancers the way I like my bean dip: 7 layer. 2:13And well, Apache and NGINX are often used as 7 layer load balancers, operating the application layer, specifically HTTP. 2:24So this specific request comes in, it hits the proxy server up front 2:29and it goes and initiates its own connection with the server, or the servers on the private network, to fulfill the request. 2:36So we're talking to those servers by proxy. 2:40Now, this gives us several key advantages. 2:43So let's take a look at some of those. 2:45And the first one is all about load balancing. 2:51And I think it's the most obvious advantage because we can route the requests to any number of the servers now, 2:59we're no longer constricted to the performance of a single server -- we can send it to the one that is least busy. 3:06Number 2 is security. 3:11Now, we're never letting the outside world know what's back here at all. 3:17All they ever see is this, the reverse proxy. 3:20Even though it's just reaching out and tasking those servers with the work 3:24to the requester, the web browser, it looks like it's all coming from right here. 3:29It takes all the credit, which is kind of rude, now that I think about it, but we'll let it slide. 3:34Now, although it sees the same request over and over again, if that is for a static non-dynamic resource, 3:42let's say a very popular image is at the top of every web page, it can do something called caching. 3:49So it can cache that resource and then it can serve it up on its own, saving time and network throughput. 3:58So at least it's trying to help there. 4:00And speaking of reducing network throughput, it can also optimize compression, and that is benefit number 4. 4:10And that compression is specifically between itself and the client, decreasing load times. 4:17And it can also handle SSL connections out to the web, 4:24allowing servers on a private protected network to communicate in plain text, 4:29which can dramatically speed up some applications. 4:32Now, typically we recommend employing encryption everywhere, but in some cases it's not practical and it's not needed. 4:41So I just wanted to put that disclaimer out there so I don't get yelled at. 4:47Okay okay, now, the point here, we came here to talk about Apache and we came here to talk about and NGINX. 4:59And they -- Apache and NGINX -- they do all this. 5:04The difference to know is that Apache, well, Apache came first. 5:12And it's been around for a long time. 5:15We're talking pre-2000 here. 5:16And it started out as a basic web server, which has been extended over time with the use of modules. 5:21So we want to enable the mod_proxy and mod_http modules to give it reverse proxy capabilities. 5:30It works, it performs well, and it's got a ton of functionality besides -- and in addition to -- being a web or reverse proxy server. 5:40But that, that wasn't good enough for Igor Sysoev, who released NGINX in 2004 with the explicit goal of outperforming Apache. 5:51Nothing like having a target painted on your back, huh? 5:54So suffice to say, NGINX does outperform Apache as a simple web server and proxy server. 6:01It is without question fast. 6:05It also has a very simple configuration, 6:10and that makes it very easy to handle large volumes of transactions, 6:14especially when it comes to simple static files. 6:18When we start getting into dynamic content, because Apache has its roots as an extensible server, 6:26that's where it really holds an edge. 6:29There's just a lot more you can do with it, albeit at the expense of speed in some cases. 6:34And I think it's also important to note here that we're talking about HTTP traffic. 6:39And it's not just web pages like here, but any HTTP traffic, including all of those REST calls. 6:47Cause you are you did watch my video about REST calls, right? 6:49Well, they're handling these REST calls which power just about every web and mobile app there is. 6:58And right now NGINX is a bit more popular in the container space. 7:02So it enjoys a bit of a popularity boost from all those containerized solutions. 7:06But as we've seen, this is a hotly contested space. 7:10And they don't need to fight -- they can be friends! 7:14It's entirely possible to have NGINX acting as your reverse proxy 7:18with several Apache web servers behind it, or vice versa. 7:23The fundamentals are largely the same. 7:25It really does come down to what fits best into your environment. 7:29So whichever solution you go with, 7:31you will enjoy a whole host of features that will keep your web data flowing 7:36quickly, safely and reliably. 7:41If you have any questions, please drop us a line below. 7:43And if you want to see more videos like this in the future, please Like and Subscribe. 7:48Thanks for watching.