A reverse proxy sits in front of a web server and receives all the requests before they reach the origin server. It works similarly to a forward proxy, except in this case itâs the web server using the proxy rather than the user or client. Reverse proxies are typically used to enhance performance, security, and reliability of the web server. For example, you can have a non-WordPress site hosted at In this article, youâll learn the basics of reverse proxy servers, how they work, what their major benefits are, and how you can use them to speed up and secure your WordPress site. Excited? Letâs start! What Is a Reverse Proxy?To understand what a reverse proxy server is, you need first to know its role and get familiar with all its related terms. When you browse the web normally by entering a domain name or clicking a link, your browser/device connects to the websiteâs server directly and starts downloading its resources. If you want to anonymize your IP address from the websites you visit, then you can use a proxy server to send all your requests to it first. Itâll forward your requests to the DNS resolver and then download the websiteâs resources from its origin server. Afterward, itâll pass on those resources to your device. This is called a forward proxy. Youâre completely hidden from the website as it thinks your request is originating from the forward proxy.
Info
Due to the way some hosting providers like Kinsta count site visits, they require users to set a header to notify their real IP address to the origin server. Hence, the privacy benefits donât apply in specific cases such as these. Apart from enhancing user privacy, a forward proxy is mainly used to bypass geographical content restrictions. For instance, if you want to watch a video thatâs blocked in your region, you can use a forward proxy with an IP address on which the video is available to view. A forward proxy works almost the same way as a Virtual Private Network (VPN), but theyâre distinct technologies with unique use cases (they can sometimes overlap though). Reverse Proxy Server vs Forward Proxy ServerA reverse proxy server acts as a front for the origin server to maintain anonymity and enhance security, just like how a user/client can use a forward proxy to achieve the same. It ensures that no user or client communicates directly with the origin server. The difference between a forward proxy vs a reverse proxy is minor, but they work differently. Both can work together as thereâs no overlap between their functioning. Typically, users/clients use a forward proxy, while origin servers use a reverse proxy. Since a server admin can control how the reverse proxy works, you can use it to enable many useful features. Weâll list all its benefits later in this post. Why Use a Reverse Proxy?Many businesses, especially large enterprises, use bespoke websites that are tailor-made to their unique needs and arenât running on WordPress. Some examples include bank and insurance websites. In other cases, a business may host their site on an external service that doesnât allow them to install any external software (e.g. WordPress). Usually, these are small to mid-sized retailers using an ecommerce platform such as Shopify. Since WordPress has robust CMS features, many businesses, including large enterprises with bespoke websites, may prefer to host their blogs using WordPress. One way to get around this problem is to install WordPress on the main websiteâs subdomain and structure the navigation menus such that users can switch easily between the main website and the blog. Since subdomains behave as a unique domain, it can affect your siteâs SEO. Even though Google treats both subdomains and subdirectories equally, it takes more effort to optimize a website for search engine rankings if itâs hosted on a subdomain than if itâs hosted in a subdirectory. Google has reaffirmed that it treats both subdomains and subdirectories equally, but some SEO experts disagree with it. And even if it doesnât affect the siteâs SEO, a site hosted in a subdirectory is simply easier to maintain. Thatâs why you can use a reverse proxy to redirect requests to the siteâs blog hosted on a separate server. For example, a bank can host their main website on their servers securely, but they can also host their WordPress-powered blog separately on a managed WordPress host like Kinsta. Unifying two different sites under a single domain name is one of the key advantages of using a reverse proxy. It helps brands keep their sites organized, professional, and maintain credibility. Learn how a reverse proxy can enhance performance, security & reliability... all in this guide Click to TweetBenefits of Using a Reverse ProxyBesides the above use case, reverse proxies also grant many other benefits. The section below discusses some of their major advantages. Load BalancingA single origin server cannot handle all the incoming traffic for a website with millions of daily unique visitors. In these cases, you can distribute the traffic smartly among a pool of many servers. Usually, all the servers will host the same content to eliminate a single point of failure, making the website more reliable. A reverse proxy is a great way to set this up as it can receive the incoming traffic before it reaches the origin server. If the origin server is overloaded or fails completely, it can distribute the traffic to other servers without affecting the site functionality. Reverse proxies can also direct the incoming requests to several servers, with each server performing a specific function itâs optimized for. The reverse proxy can then gather responses from all the servers and deliver them to the client. Since we use most of the popular reverse proxies primarily for load balancing, theyâre also referred to as Load Balancers. Global Server Load Balancing (GSLB)GSLB is an advanced load balancing method for distributing website traffic among many servers placed strategically around the world. Itâs typically done via anycast routing technique, where the reverse proxy picks the server node based on the fastest travel time between the client and the server. Not only does GSLB increase the siteâs reliability and security considerably, it also reduces latency and load times, thereby enhancing user experience. You can use GSLB with other network optimization techniques such as Spoon Feeding to free up the origin serversâ computational resources even more. Though you can set up Global Server Load Balancing manually on your server, itâs usually taken care of by dedicated CDNs such as Cloudflare and KeyCDN (which also powers Kinsta CDN). Kinsta serves all the websites hosted with it through a Load Balancer powered by Google Cloud Platform. Enhanced SecurityReverse proxies can cloak the IP address and other characteristics of origin servers. Thus, your websiteâs origin server can maintain its anonymity better, increasing its security significantly. Since the reverse proxy will receive all the traffic before it reaches the main server, any attackers or hackers will find it harder to target your website with security threats such as DDoS attacks. You can use a strict firewall to harden the reverse proxy with tighter security against common cyber attacks. Without a reverse proxy installed, it is difficult to remove malware or start takedowns.
Info
Kinsta uses reverse proxies in its backend architecture and offers free WordPress hack fixes to all the websites it hosts. A reverse proxy like HAProxy can add basic HTTP access authentication to a web server that doesnât have it enabled. You can also use a reverse proxy to add centralized authentication for various types of requests. Powerful CachingYou can use a reverse proxy for web acceleration purposes by caching both static and dynamic content. This can reduce the load on the origin server, resulting in a faster website. For instance, if your origin server is in the USA and a user from Europe visits your website, then you can serve a cached version of your site from a reverse proxy server in Europe. Since the reverse proxy is closer to the user than the origin server, the website will take less time to load, making it perform superbly.
We grew our traffic 1,187% with WordPress.
Weâll show you how.
Join 20,000+ others who get our weekly newsletter with insider WordPress tips!
Success! Thanks for subscribing
You will receive the next issue of the Kinsta Newsletter within a week.
Subscribe to the Kinsta newsletter
Varnish and Nginx FastCGI are prominent examples of reverse proxies that are used for caching web content. If your site is hosted with Kinsta, you donât have to worry about caching as Kinsta takes care of all the caching legwork for you. Superior CompressionServer responses use up a lot of bandwidth. Compressing server responses (e.g. with gzip) before sending them to the client can reduce the amount of bandwidth required, speeding up server responses over the network. A reverse proxy is ideal to compress server responses as it sits in between the origin servers and the client. Optimized SSL EncryptionEncrypting and decrypting SSL/TLS requests for each client can be highly taxing for the origin server. A reverse proxy can take up this task to free up the origin serverâs resources for other important tasks, like serving content. Another advantage of offloading SSL/TSL encryption and decryption is to reduce latency for clients that are geographically distant from the origin server. You can also opt for a reverse proxy with specialized SSL/TLS acceleration hardware to optimize this task even further. Such a reverse proxy is called an SSL/TLS termination proxy. Some servers like Varnish do not support SSL/TSL protocols, so an SSL/TSL termination reverse proxy can help secure the traffic passing through them. Better A/B TestingMost A/B testing tools require you to use external JavaScript libraries to load their functions. However, loading third-party scripts can slow down your page load times and create a choppy experience for users. Instead, you can use a reverse proxy to create two separate flows at the server level itself. For example, you can use Nginxâs You can refer to tutorials on Nginx and freeCodeCamp to learn more about performing A/B testing with a reverse proxy. Monitoring and Logging TrafficA reverse proxy captures any requests that go through it. Hence, you can use them as a central hub to monitor and log traffic. Even if you use multiple web servers to host all your websiteâs components, using a reverse proxy will make it easier to monitor all the incoming and outgoing data from your site. The Most Popular Reverse ProxiesAs per W3Techs, almost 83% of the websites use no reverse proxy services that they monitor. Of the 17% websites that use a reverse proxy (listed above), youâll notice that most of them are CDNs. Thatâs because most reverse proxies hide their existence by default as a safety precaution. Hence, you cannot rely on website monitoring services like W3Techs to find which reverse proxies are the most popular ones. From our research and experience, the most popular reverse proxies in use today are: NginxNginx is an open source web server that can also serve as a reverse proxy. Apart from being used to host websites, itâs also one of the most widely used reverse proxy and load balancing solutions. As per Netcraft, over 479 million web servers were using Nginx in December 2019, making it the leader in the web server market share. Nginx provides all the reverse proxy benefits discussed above, plus more. It improves web performance, security, reliability, and scalability. You can configure Nginx using its configuration file, which is also hot reloadable. But you can also use Nginx Plus, a commercial offering, to get access to API-based configuration options and other features suitable for large enterprise websites. Kinsta powers all its websites with Nginx. It has ranked in Review Signalâs Top Tier web hosting status in every category it has competed in. Some other major companies that use Nginx are MaxCDN, Cloudflare, and Netflix. Setting up Nginx as a basic reverse proxy is simple. Nginx also provides you with various directives to customize your serverâs reverse proxy as per your requirements. Weâll discuss how to do this in a later section. If youâre a Kinsta customer, youâll also learn how to use a reverse proxy for websites hosted with Kinsta in the same section. VarnishVarnish is an open source HTTP reverse proxy with a built-in cache engine. Itâs designed primarily for high-traffic websites that serve dynamic content. You can also use Varnish as a load balancer, a web app firewall (WAF), and an edge authentication and authorization server. It works on all modern versions of Linux and FreeBSD, being used mainly as a front for Nginx or Apache web servers. Varnishâs powerful and highly flexible Varnish Configuration Language (VCL) lets you define various features such as handling HTTP requests, caching, and connecting to one or more web servers. For this reason, many CDNs use Varnish as their main foundation for delivering content swiftly. Varnish also supports Edge Side Includes (ESI), a language that helps you to reuse sections of one web page in other web pages. If your website uses a lot of repeated content in different pages, ESI can help you speed up your siteâs page load times by caching frequently used sections. You can extend Varnish with its various modules (VMODs). Head to Varnishâs official tutorial to learn how to set up Varnish as a reverse proxy for WordPress. Apache Traffic ServerApache Traffic Server is an open source caching proxy server. Itâs popular for its fast, scalable features. It was a commercial product developed by Yahoo! long ago, but they made it open source and donated it to the Apache Foundation for maintenance. Several major content networks and CDNs like Comcast, Akamai, LinkedIn, Yahoo, and Apple use Apache Traffic Server to power their technology. You can also use Apache HTTP Server (Apache httpd), an HTTP server daemon, to set up a reverse proxy on your web server. Apart from acting as a basic web server, it also helps you serve static and dynamic content to users. Youâll learn how to set up Apache as a reverse proxy later in this article. HAProxyHAProxy is an open source reverse proxy and load balancer. Itâs designed to integrate with most existing web server architectures, including Linux distributions and cloud platforms. Similar to Nginx, HAProxy uses an event-driven I/O model and supports splitting requests across multiple worker processes. For HTTP requests, HAProxy performs exceptionally well even under heavy loads. Some of the highest traffic websites on the internet such as Airbnb, Reddit, Instagram, Stack Overflow, Tumblr, GitHub, and Imgur use HAProxy to deliver their websites efficiently. Discussing how to implement HAProxy is beyond the scope of this article, but you can refer to their documentation to understand how it works. Note: Traefik and Envoy are two other open source alternatives to HAProxy. Theyâre both high-performant reverse proxies and load balancers with many advanced features. Some other popular reverse proxies are AWS Elastic Load Balancer, GLBC, DigitalOcean Load Balancer, and Google Cloud Load Balancer. For an exhaustive list of the top reverse proxies and load balancers in use today, you can check out Stackshare.io. Reverse Proxy: Use Cases for WordPress SitesThere are mainly three use cases for employing a reverse proxy for WordPress sites, including sites hosted at Kinsta. Weâll only use Nginx for this example, as itâs the most popular reverse proxy used for WordPress sites today. But the same basic principles will apply to other reverse proxies. Reverse proxies are often challenging to install, configure, and support. For this reason, Kinsta offers a $50 monthly add-on subscription for each reverse proxy that you need help with setting up. You can reach out to Kinstaâs support team for further details. 1. Main and Proxied Sites Hosted on the Same ServerIf both the main site and the proxied site are hosted on the same server, the main site can run on a WordPress installation, while a separate WordPress installation powers the proxied site. As youâll have access to both the sites and their shared web server, you can set up the reverse proxy rules for the main site, and then configure the proxied site to load from the reverse proxy. If youâre hosting both these sites at Kinsta, then you can reach out to Kinstaâs support team and request them to set up the reverse proxy for you. Hereâs the procedure you need to follow:
Here are the standard Nginx reverse proxy directives used by Kinsta to load a subdirectory site over a reverse proxy:
In the above code, you need to replace the The
Note: A proxied site cannot create URLs that duplicate the same subdirectory under which the proxied site loads. For instance, a proxied site at Need a blazing-fast, secure, and developer-friendly hosting for your sites? Kinsta is built with WordPress developers in mind and provides plenty of tools and a powerful dashboard. Check out our plans 2. Only the Proxied Site Hosted on Your ServerIf you only have access to the proxied site and its web server, then you need to contact the server admin of the main site and ask them to set up the reverse proxy rules for you. To do that, you must follow the same steps outlined above, except in this case you must configure the rules on two different servers. To host your proxied site with Kinsta, add a domain to the site which will point to the reverse proxy. Usually, subdomain suits this purpose (e.g. After setting up your proxied site on Kinsta, you can contact Kinsta support team to configure the proxied site to load over a reverse proxy. However, setting up the reverse proxy falls outside the scope of Kinsta support as only the server admin can take care of it. 3. Only the Main Site Hosted on Your ServerIf you only have access to the main site and its web server, then you should set up the reverse proxy and configure its rules to load the proxied site from an external host. Installing and configuring the proxied site to load over the reverse proxy is the responsibility of the secondary serverâs admin. Having your main site hosted at Kinsta will grant you access to Kinstaâs support team. You can raise a support ticket with them to add the standard reverse proxy rules listed earlier in this article. You can also have any additional customizations added to those rules if needed. In this scenario, youâre fully responsible for configuring the proxied site to load it properly over the reverse proxy. How to Set Up Nginx as a Reverse ProxyIf Kinsta doesnât host your website and you manage your servers, then you must set up the reverse proxy yourself and configure it to point towards the proxied site. Depending on your web serverâs operating system, you can install Nginx differently. For Linux distributions, you can use various Nginx packages based on your Linux distributionâs version. In the example below, weâve installed the primary site at To begin, access your serverâs terminal via SSH. Then use the
Next, you need to configure Nginx to proxy requests for domains hosted on Apache. To do that, create a new virtual host file. Here, Iâm using the nano editor to add the code, but you can use any code editor of your choice.
Then set Nginx directives to forward requests to Apache by adding the following
In the code above, Iâm defining a subdirectory Note: Ensure that the proxied website is installed and ready to be served before you make any changes. You can learn more about all the reverse proxy directives used here in Nginxâs detailed index of directives. Save the virtual host file. Then activate the new virtual host by creating a symlink for the files named
After that, test Nginx for any configuration errors.
If there are no errors, reload Nginx to enforce the changes.
Youâve successfully set up Nginx to work as a reverse proxy now. To confirm this, you can use the phpinfo() function to check the PHP variables loaded when you visit your proxied site. Under the You can speed up serving your WordPress site over Nginx by using the fastcgi_cache and ngx_cache_purge modules. While the first module will cache your site, the second module will automatically purge the cache based on specific events (e.g. publishing or editing a WordPress post/page). You can use the Nginx Cache Controller WordPress plugin to control Nginxâs proxy server cache directly from your WordPress admin dashboard. If youâre using a WordPress Multisite installation, then you can use the Nginx Helper plugin to do the same. Check out Nginxâs main documentation and Nginx WordPress setup guide for a detailed overview of how to work with Nginx and WordPress. How to Set up Apache as a Reverse ProxyBefore you begin, make sure you have two websites up and running at Start configuring Apache by opening your serverâs terminal via SSH and enabling Apacheâs proxy module.
Running the above command will most likely restart Apache to reload the newly defined directives. Next, edit your main serverâs virtual hosts file to create a reverse proxy. Hereâs the code you need to add:
The ProxyPass directive will create a reverse proxy for the paths specified, while the ProxyPassReverse directive will intercept the HTTP response headers sent through this reverse proxy and rewrite them to match the Apache server. After saving the file, you need to edit your
Finally, you need to update your WordPress siteâs database to add the configuration values for the
You should now be able to visit Limitations of a Reverse Proxy
Choosing Between a CDN and a Reverse ProxyCDNs are an advanced form of reverse proxy with most of the configuration and maintenance taken care of by a third-party. They can provide amazing performance benefits to your WordPress site with minor effort from your end. Not only do CDNs cache content and serve it swiftly to users, but they also reduce load on your origin servers, lower bandwidth costs, provide an additional layer of security, boost your siteâs SEO, and help you scale your website better.
Info
Kinsta CDN has very low TTFB and enhances your siteâs performance significantly. Every Kinsta account comes with a free tier of Kinsta CDN and you can set it up easily in seconds. For more information, you can refer to Kinsta CDNâs comparison with a traditional CDN. Youâll notice that most of the benefits provided by CDNs are the same as those provided by reverse proxies. So, should you choose a CDN over a reverse proxy, or vice versa? Thereâs no reason you must settle with just one. If you already have a reverse proxy installed, youâll still see speed and performance gains from using a CDN. Both their caches layer well, and if you have any unique request handling needs (e.g. dynamic content, ecommerce), then you can configure it easily with some custom headers passed on by the CDN or the reverse proxy. Want to learn more about reverse proxy servers? This article covers... how they work, major benefits, how you can use them to speed up and secure your WordPress site.Click to TweetSummaryWordPress is highly flexible. You can use it as a blog, an ecommerce site, or even a Learning Management System. In most cases, you can customize WordPress to suit your unique requirements. However, sometimes you may have to use a separate domain or a secondary server to host an additional site. As discussed earlier, it may be because of using different technology stacks for a big enterprise site or launching a WordPress blog for a pre-existing non-WordPress site. A reverse proxy can help in both these cases, helping you get the most out of WordPress without giving up the main website and starting over. The post How to Set up a Reverse Proxy (Step-By-Steps for Nginx and Apache) appeared first on Kinsta Managed WordPress Hosting.
0 Comments
Leave a Reply. |
AuthorEmpreendedor digital, blogueiro e ativista ambiental. Arquivos:
November 2020
Categorias
|