How To Use Apache as a Reverse Proxy with mod_proxy on CentOS 7(1)proxy<h1 style="text-align: center;">How To Use Apache as a Reverse Proxy with mod_proxy on CentOS 7</h1><p style="text-align: right;">By <a href="https://www.digitalocean.com/community/users/mati">Mateusz Papiernik</a><br /> </p><h3 id="introduction">Introduction</h3><p>A <em>reverse proxy</em> is a type of proxy server that takes HTTP(S) requests and transparently distributes them to one or more backend servers. Reverse proxies are useful because many modern web applications process incoming HTTP requests using backend application servers which aren’t meant to be accessed by users directly and often only support rudimentary HTTP features.</p><p>You can use a reverse proxy to prevent these underlying application servers from being directly accessed. They can also be used to distribute the load from incoming requests to several different application servers, increasing performance at scale and providing fail-safeness. They can fill in the gaps with features the application servers don’t offer, such as caching, compression, or SSL encryption too.</p><p>In this tutorial, you’ll set up Apache as a basic reverse proxy using the <code>mod_proxy</code> extension to redirect incoming connections to one or several backend servers running on the same network. This tutorial uses a simple backend written with the with <a href="http://flask.pocoo.org/">Flask web framework</a>, but you can use any backend server you prefer.</p><h2 id="prerequisites">Prerequisites</h2><p>To follow this tutorial, you will need:</p><ul> <li>One CentOS 7 server set up with <a href="https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7">this initial server setup tutorial</a>, including a sudo non-root user.</li> <li>Apache 2 installed on your server by following Step 1 of <a href="https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-7">How To Install Linux, Apache, MySQL, PHP (LAMP) Stack on CentOS 7</a>.</li> <li>Optionally, the <code>nano</code> text editor installed with <code>yum install nano</code>. CentOS comes with the <code>vi</code> text editor by default, but <code>nano</code> can be more user friendly.</li></ul><h2 id="step-1-—-introducing-necessary-apache-modules">Step 1 — Introducing Necessary Apache Modules</h2><p>The modules that are needed to use Apache as a reverse proxy include <code>mod_proxy</code> itself and several of its add-on modules, which extend its functionality to support different network protocols. Specifically, we will be using:</p><ul> <li><code>mod_proxy</code>, the main proxy module Apache module for redirecting connections; it allows Apache to act as a gateway to the underlying application servers.</li> <li><code>mod_proxy_http</code>, which adds support for proxying HTTP connections.</li> <li><code>mod_proxy_balancer</code> and <code>mod_lbmethod_byrequests</code>, which add load balancing features for multiple backend servers.</li></ul><p>All four modules are enabled by default on a fresh CentOS 7 installation. You can verify that they are enabled by running:</p><p>$ httpd -M</p><p>The command output will list all enabled Apache modules. The four lines you’re looking for are the aforementioned module names:</p><pre><code langs=""> proxy_module (shared). . . lbmethod_byrequests_module (shared). . . proxy_balancer_module (shared). . . proxy_http_module (shared)</code></pre><h2 id="step-2-—-creating-backend-test-servers">Step 2 — Creating Backend Test Servers</h2><p>Running some simple backend servers is an easy way to test if your Apache configuration is working properly. Here, we’ll make two test servers which respond to HTTP requests with printing a line of text. One server will say <strong>Hello world!</strong> and the other will say <strong>Howdy world!</strong>.</p><p><strong>Note:</strong> In non-test setups, backend servers usually all return the same kind of content. However, for this test in particular, having the two servers return different messages makes it easy to check that the load balancing mechanism uses both.</p><p>Flask is a Python microframework for building web applications. We’re using Flask to create the test servers because a basic app requires just a few lines of code. You don’t need to know Python to set these up, but if you’d like to learn, you can look at <a href="https://www.digitalocean.com/community/tags/python?type=tutorials">these Python tutorials</a>.</p><p>Let’s install the IUS package repository files first. IUS (Inline with Upstream Stable) is a community project that brings up-to-date versions of select software to CentOS, including Python 3.</p><h2 id="step-3-—-modifying-the-default-configuration-to-enable-reverse-proxy">Step 3 — Modifying the Default Configuration to Enable Reverse Proxy</h2><p>In this section, we will set up the default Apache virtual host to serve as a reverse proxy for single backend server or an array of load balanced backend servers.</p><p><strong>Note</strong>: In this tutorial, we’re applying the configuration at the virtual host level. On a default installation of Apache, there are no virtual hosts configured. We will be creating a single, default virtual host that will catch all traffic. However, you can use all those configuration fragments in other virtual hosts as well. To learn more about virtual hosts in Apache, you can read this <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7">How To Set Up Apache Virtual Hosts on CentOS 7</a> tutorial.</p><p>If your Apache server acts as both HTTP and HTTPS server, your reverse proxy configuration must be placed in both the HTTP and HTTPS virtual hosts. To learn more about SSL with Apache, you can read this <a href="https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-apache-for-centos-7">How To Create a SSL Certificate on Apache for CentOS 7</a> tutorial.</p><p>Create the new default virtual host by creating a new empty Apache configuration file in <code>/etc/httpd/conf.d</code> directory using <code>nano</code> or your favorite text editor.</p><pre>$<code langs="">sudo nano /etc/httpd/conf.d/default-site.conf</code></pre>
ArticleStore: zero_addressArticleStore: has not pausedArticleStore: invalid contractArticleStore: zero_addressArticleStore: has pausedArticleStore: zero_addressArticleStore: zero_addressArticleStore: has not paused
ArticleStore: zero_addressArticleStore: has not pausedArticleStore: invalid contractArticleStore: zero_addressArticleStore: has pausedArticleStore: zero_addressArticleStore: zero_addressArticleStore: has not paused
not address_admin_contractpermission deniedpermission deniedBeyond the MAX_NUMBERbeyond the borderbeyond the borderpermission deniedThe template has existedpermission deniedThe template is not existedMust has at least one template
not address_admin_contractpermission deniedpermission deniedpermission deniedThe ico has not startedico has not startedpermission deniedpermission denied
not address_admin_contractpermission deniedpermission deniedpermission deniedpermission deniedhas a independent pricepermission deniedhas not a independent pricepermission deniedhas a independent pricepermission deniedhas a independent pricepermission deniedinsufficient fee
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Da; V[PPPPPPPPV[`your not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DRPP`
` RPPPPPPPV[`@Your eth is not enough to be gro`Dsilly dev, you already did thatSafeMath add failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersSafeMath sub failedits not ready yet. check ?eta isorry humans only
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Dyour not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DYour eth is not enough to be gro`Dsilly dev, you already did thatSafeMath add failedSafeMath sub failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersits not ready yet. check ?eta isorry humans only
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Dyour not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DYour eth is not enough to be gro`Dsilly dev, you already did thatSafeMath add failedSafeMath sub failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersits not ready yet. check ?eta isorry humans only
you need register the addresssorry humans onlysorry game paused you need register the addressyou need buy one or more keysthe round is endthe round maxKeysaFVV[[PPPPPPPPPPPV[` you need register the addresssorry game pausedsorry humans onlyumm..... you have to pay the na you need register the addressstring must be between 1 and 32 string cannot start or end with string cannot start with 0xstring cannot start with 0Xstring contains invalid charactestring cannot contain consecutivstring cannot be only numbersUP[[PPPPPPPPPV[`the rounds has endsorry that names already taken
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Dyour not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DYour eth is not enough to be gro`Dsilly dev, you already did thatSafeMath add failedSafeMath sub failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersits not ready yet. check ?eta isorry humans only
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Dyour not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DYour eth is not enough to be gro`Dsilly dev, you already did thatPPPPPPPV[a7ha]nV[`SafeMath add failedSafeMath sub failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersPPPPPPPPPV[aO%a]nV[`its not ready yet. check ?eta isorry humans only
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Dyour not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DYour eth is not enough to be gro`Dsilly dev, you already did thatPPPPPPPV[a7ha]nV[`SafeMath add failedSafeMath sub failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersPPPPPPPPPV[aO%a]nV[`its not ready yet. check ?eta isorry humans only
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Dyour not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DYour eth is not enough to be gro`Dsilly dev, you already did thatSafeMath add failedSafeMath sub failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersPPPPPPPPPV[aNFa\its not ready yet. check ?eta isorry humans only
hey there buddy, you dont even h`Da+WV[PPPPPPPPPPV[`@derp, that games already been re`Dsilly player, that game doesn't `Dhey there buddy, you dont even h`Dsorry that names already takenumm... thats not a name you ownsetRegistrationFeesetRegistrationFeestring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numberssorry that names already takenMSFun checkSigner failed - 0 not`Dumm..... you have to pay the namsg sender is not a devsorry humans only
pocket lint: not a valid currenc`Dfomo3d already activatedpocket lint: not a valid currenc`Dyour not playerNames contract...`Dpocket lint: not a valid currenc`Dyour not playerNames contract...`DYour eth is not enough to be gro`Dsilly dev, you already did thatSafeMath add failedSafeMath sub failedSafeMath mul failedstring must be between 1 and 32 `Dstring cannot start or end with `Dstring cannot start with 0xstring cannot start with 0Xstring contains invalid characte`Dstring cannot contain consecutiv`Dstring cannot be only numbersPPPPPPPPPV[aNFa\its not ready yet. check ?eta isorry humans only