{"id":1428,"date":"2014-11-12T13:19:30","date_gmt":"2014-11-12T18:19:30","guid":{"rendered":"http:\/\/www.gtcomm.net\/blog\/?p=1428"},"modified":"2020-03-06T12:31:22","modified_gmt":"2020-03-06T17:31:22","slug":"using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/","title":{"rendered":"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers"},"content":{"rendered":"<p>How do you pronounce Nginx, and what exactly is it? Nginx is pronounced &#8220;engine-ex,&#8221; and it basically serves as a reverse proxy server. Before understanding what a reverse proxy server is, you need to know what a proxy server is. <!--more-->As the name proxy implies, a server is acting as a substitute. In the case of a proxy server, it accepts requests from clients and gets resources from servers. The proxy server then sends them to the client. How can you reverse that? With a reverse proxy server, the client doesn\u2019t know it is talking to the proxy. The client makes a request to the server, hits the proxy instead, and the proxy passes the request along to the server. The server sends the response to the proxy, the proxy sends the response to the client as if it came from the server, and the client is none the wiser.<\/p>\n<p>Why might you use a reverse proxy server? It is a good way to manage load balancing. If one client thinks it is talking to one server, imagine what happens when 100 clients hit that server? What about 1,000 or 10,000? Or, what if it is Christmas and you\u2019re Amazon, and perhaps it&#8217;s 1 million or more? That one server can\u2019t handle the whole load. You need to spread the load around, but you don\u2019t want to have to tell each client to talk to a different server. From the clients\u2019 perspective, they all need to talk to the same server. By introducing a reverse proxy server as a load balancer, you can distribute these requests across multiple servers. The clients don\u2019t care as long as they get their responses. The clients still think it is just one machine. But the reverse proxy server is able to spread the load across multiple servers, so response times can stay optimal without having to push any changes out to clients. In short, the load balancer spreads the workload across multiple systems to avoid overloading a single resource.<\/p>\n<p>That\u2019s where Nginx comes in. It is an open-source, high-performance reverse proxy server that is used as a load balancer. Once configured, requests come in and the load-balancing methodology takes over to spread the workload. You can use round-robin technique to just loop through all the different servers for each request, or you can take into account which server has the fewest active connections, or you can just hash the IP address to spread things around.<\/p>\n<p>One nice thing that Nginx adds is session persistence. While HTTP is stateless, Nginx manages its way around that to preserve some cached data such as for a shopping cart of long results pagination. And it will make sure that repeated requests from the same client will be routed to the same shared server to actually maintain session-specific data.<\/p>\n<p>There is much more to Nginx than meets the eye. Even if you\u2019re not in a load-balancing situation, using Nginx in front of, say, an Apache server can prove helpful for high-demand servers. Nginx offers its own caching mechanism. For a somewhat static page, Apache could handle the rendering of the first request. Nginx would then send the response back to the first client. If clients 2 through 10,000 came in quickly behind it, the Apache server would be none the wiser, as the Nginx server could just send back the same response to them all, provided all are within the maximum age time you\u2019ve set.<\/p>\n<p>There are pros and cons to using anything. In the case of Nginx, if you\u2019re a low-traffic site, there is no benefit to all the headaches of configuring a secondary server. Apache servers serve about 40 percent of the web. Nginx is on perhaps 15 percent. It may have many big-name clients such as Netflix and Facebook, but it doesn\u2019t have the audience, wide appeal and long history of Apache. A recent case study (<a href=\"https:\/\/www.nginx.com\/blog\/many-web-sites-use-nginx-august-2014\/\">http:\/\/nginx.com\/resources\/references\/<\/a>) says it&#8217;s on 40 percent of the busiest web sites, but who says Apache\u2019s 40 percent of the whole web isn\u2019t more than 40 percent of the busiest? Given that some sites pair Nginx with Apache, it wouldn\u2019t surprise me that the Apache percentage would be even higher. Of course, it isn\u2019t all bad. You can use Nginx to proxy not just web requests but also email, too. It streams media as well as standard web pages. No wonder Netflix is such a big user here. It uses memory much more efficiently than Apache without needing to create separate processes per request. It even has tools for activity monitoring.<\/p>\n<p>Most people have high hopes of hitting it big \u2014\u00a0of possibly having that next Pet Rock, Rubik\u2019s Cube, or Dancing Elmo, where everyone wants one and your website will be overrun with orders. With something like Nginx, you can help make sure your website can handle the demands and spread the load across as many servers as you end up needing. Speed is king to getting those orders, and using a reverse proxy server to help with load balancing goes a long way to getting things done quickly.<\/p>\n<p>If you are interested in Nginx as an http server, I recommend you to have a look at this <a href=\"https:\/\/www.globo.tech\/learning-center\/nginx-the-best-http-server\/\">benchmark on Nginx server compared to other alternatives<\/a>.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How do you pronounce Nginx, and what exactly is it? Nginx is pronounced &#8220;engine-ex,&#8221; and it basically serves as a reverse proxy server. Before understanding what a reverse proxy server is, you need to know what a proxy server is.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":4,"featured_media":1429,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[25,6],"class_list":["post-1428","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ha-clustering","tag-nginx","tag-software"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers - Globo.Tech<\/title>\n<meta name=\"description\" content=\"Nginx, pronounced &quot;engine-ex,&quot; serves as a reverse proxy server. It is an open-source, high-performance reverse proxy server that is used as a load balancer\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"Nginx, pronounced &quot;engine-ex,&quot; serves as a reverse proxy server. It is an open-source, high-performance reverse proxy server that is used as a load balancer\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2014-11-12T18:19:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-06T17:31:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"500\" \/>\n\t<meta property=\"og:image:height\" content=\"340\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Eric Simard\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eric Simard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/\",\"name\":\"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg\",\"datePublished\":\"2014-11-12T18:19:30+00:00\",\"dateModified\":\"2020-03-06T17:31:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/2202ee355cd2897b4751d2f3ffcd56f1\"},\"description\":\"Nginx, pronounced \\\"engine-ex,\\\" serves as a reverse proxy server. It is an open-source, high-performance reverse proxy server that is used as a load balancer\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#primaryimage\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg\",\"contentUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg\",\"width\":500,\"height\":340,\"caption\":\"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/2202ee355cd2897b4751d2f3ffcd56f1\",\"name\":\"Eric Simard\",\"description\":\"I am Eric Simard, best father in the world and account manager at GloboTech Communications located in the beautiful city of Montreal. Passionate about the hosting world and technologies, I take great pleasure in offering the best solutions for my clients. Follow me through my journey in the exciting hosting world on my different blogs!\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers - Globo.Tech","description":"Nginx, pronounced \"engine-ex,\" serves as a reverse proxy server. It is an open-source, high-performance reverse proxy server that is used as a load balancer","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/","og_locale":"en_US","og_type":"article","og_title":"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers - Globo.Tech","og_description":"Nginx, pronounced \"engine-ex,\" serves as a reverse proxy server. It is an open-source, high-performance reverse proxy server that is used as a load balancer","og_url":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/","og_site_name":"Globo.Tech","article_published_time":"2014-11-12T18:19:30+00:00","article_modified_time":"2020-03-06T17:31:22+00:00","og_image":[{"width":500,"height":340,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg","type":"image\/jpeg"}],"author":"Eric Simard","twitter_misc":{"Written by":"Eric Simard","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/","url":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/","name":"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#primaryimage"},"image":{"@id":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg","datePublished":"2014-11-12T18:19:30+00:00","dateModified":"2020-03-06T17:31:22+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/2202ee355cd2897b4751d2f3ffcd56f1"},"description":"Nginx, pronounced \"engine-ex,\" serves as a reverse proxy server. It is an open-source, high-performance reverse proxy server that is used as a load balancer","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#primaryimage","url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg","contentUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2014\/11\/using_nginx_as_reverse_proxy_http_https_for_load_balancing_multiple_apache_server.jpg","width":500,"height":340,"caption":"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/using-nginx-as-reverse-proxy-httphttps-for-load-balancing-multiple-apache-servers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"Using Nginx as reverse proxy (HTTP\/HTTPS) for load-balancing multiple Apache servers"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/2202ee355cd2897b4751d2f3ffcd56f1","name":"Eric Simard","description":"I am Eric Simard, best father in the world and account manager at GloboTech Communications located in the beautiful city of Montreal. Passionate about the hosting world and technologies, I take great pleasure in offering the best solutions for my clients. Follow me through my journey in the exciting hosting world on my different blogs!","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/1428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=1428"}],"version-history":[{"count":5,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/1428\/revisions"}],"predecessor-version":[{"id":4837,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/1428\/revisions\/4837"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media\/1429"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=1428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=1428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=1428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}