A reverse proxy is a proxy server that works between web servers and users. It masks the web server’s Internet Protocol (IP) address, protecting its identity from clients.
Reverse proxies intercept requests on behalf of the server. 23% of websites use reverse proxies. This translates to over 26 million websites, and over 25 million use Nginx.
You do not have to have a major website to use a reverse proxy. Continue reading to learn how to set up your reverse proxy using Nginx and Apache.
🔑 Key Takeaways
- A reverse proxy compresses data and stores frequently accessed content in the cache, enhancing web traffic speed.
- Apache serves as web server software, linking visitors’ devices to your site, and enabling them to access its content.
- Reverse proxies shield internal servers, serving as the website’s front end and preventing direct entry.
- The initial stage to establish a reverse proxy effectively is selecting suitable software.
How To Set Up Your Own Reverse Proxy?
Reverse proxy servers add extra control and ensure smooth network traffic flow between clients and servers. It can also direct requests based on parameters like the user’s device and location.
This type of proxy server is commonly used for load balancing. It distributes client requests among multiple servers to optimize speed and capacity.
A reverse proxy accelerates web traffic by compressing data and caching frequently requested content.
With 30,000 websites hacked daily worldwide, the importance of security is clear. Reverse proxy servers step in by safeguarding server identities and thwarting cyberattacks. They also simplify access to multiple servers using just one URL, regardless of network complexity.
Setting up your reverse proxy is relatively easy. The following sections discuss using Nginx and Apache as reverse proxy servers.
Using Nginx As A Reverse Proxy
Nginx, pronounced “engine-ex,” is an open-source web server known for its speed and reliability. It can act as a reverse proxy, load balancer, and caching solution.
💡 Did You Know When setting up a Reverse Proxy, managing a heavily visited website, or operating an e-commerce platform, you can configure a reverse proxy for your server. The recommended approach is establishing it using the Nginx open-source reverse proxy software. |
Many big companies use this software for their websites and online services. Here are the steps to set up Nginx as a reverse proxy:
Step 1: Update Your System And Install Nginx
Begin by updating the system and installing Nginx. Execute the following commands:
sudo apt update sudo apt install nginx |
Start the Nginx service upon completing the installation. Use the command:
sudo systemctl start nginx |
Enable Nginx with the following:
sudo systemctl enable nginx |
After enabling Nginx, you will receive the following output confirming its activation:

To verify that Nginx is running correctly, check its status with this command:
sudo systemctl status nginx |
Ensure that the output confirms that Nginx is running fine.

Step 2: Configure Nginx As A Reverse Proxy
Make a configuration file for the reverse proxy settings:
nano /etc/nginx/conf.d/custom_proxy.conf |
In this file, add the following configuration lines:
server {
listen 80;
listen [::]:80;
server_name myexample.com;
location / {
proxy_pass http://localhost:3000/;
}
}
Save the file and exit the editor. Then, create a link for the new proxy configuration file using the command:
ln -s /etc/nginx/conf.d/custom_server.conf |
Test the configuration.
To check the Nginx configuration for any errors, run the following command:
sudo nginx –t |
The output should look like this:

If the output indicates that the Nginx configuration is correct without any errors, proceed to restart Nginx using the command:
sudo nginx -s reload |
Once you set up the Nginx reverse proxy successfully, it will start routing any incoming traffic to the specified backend server.
What is the Best Proxy Server?

Smartproxy
Smartproxy is a top-rated proxy provider trusted by many. Its 40 million+ proxies from 195+ locations help bypass CAPTCHAs, geo-blocks, and IP bans. It offers a free trial and has a high rating of 4.7 on Trustpilot with 89% 5-star ratings, making it one of the best in the industry.
Setting Up Apache As A Reverse Proxy
Apache is a web server software that connects visitors’ devices to your website, allowing them to view its content.
💡 Did You Know? As of May 2023, Apache leads the web server market with a 41.30% user share, owing to its speed, reliability, and security. Nginx follows for its strong performance and scalability. |
It handles HTTP requests and delivers web pages. Apache also makes the site functional and influences its performance.
Setting up Apache as a reverse proxy can be done by following these steps:
Step 1: Install Apache
First, you must install Apache to set it up as a reverse proxy. Use the following command to do this:
$ sudo yum install httpd |
The following modules must be installed and activated on the Apache server:
- mod_proxy: Responsible for redirecting connections
- mod_proxy_http: Adds support for proxying HTTP
Check if these modules are installed and activated by running the following command:
$ httpd -M |
If these modules are not on the list, enable them in the Apache configuration file (httpd.conf). Add these lines to the file:
$ sudo vim /etc/httpd/conf/httpd.conf LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so |
Step 2: Save And Restart Apache
Relaunch Apache to apply the changes:
sudo systemctl httpd restart |
Step 3: Configure The Backend Test Server
On the backend server (where you have also installed Apache), create an HTML page for testing. It should have the following files:
Save and close the file. Restart Apache to save the changes. Use this URL to test the page:
http://192.168.1.50 |
Step 4: Configure A Primary Reverse Proxy
To set up the reverse proxy, open the Apache configuration file. Add these lines:
$ sudo vim /etc/httpd/conf/httpd.conf <VirtualHost *:80> ProxyPreserveHost On ProxyPass / http://192.168.1.50/ ProxyPassReverse / http://192.168.1.50/ </VirtualHost> |
The configuration above redirects any requests received at ‘http://192.168.1.50/‘. Restart Apache.
$ sudo systemctl restart httpd |
If you want, you can include another port in the URL. Using Apache Tomcat as a backend server on port 8080, use the following entries in httpd.conf:
<VirtualHost *:80> ProxyPreserveHost On ProxyPass / http://192.168.1.50:8080/test/ ProxyPassReverse / http://192.168.1.50:8080/test/ </VirtualHost> |
Step 5: Testing The Reverse Proxy
To test the reverse proxy, open a web browser. Enter the following URL:
http://192.168.1.100/ |
The reverse proxy server’s IP address is 192.168.1.100 in this case. If everything is configured correctly, you should see the page hosted on the backend server.
✅ Pro Tip: Reverse proxies serve various purposes, including safeguarding backend servers from harmful traffic. Encountering a “504 Gateway Time-Out” error? That’s the reverse proxy flagging an inaccessible backend server. Learn more in our article about comparing forward and reverse proxies. |
Pros And Cons Of Reverse Proxies
Using reverse proxies has a lot of advantages. However, it also comes with limitations.
Check out the pros and cons of reverse proxies in the table below:
Pros | Cons |
Protects internal servers by acting as the face of the website and blocking direct access | Can track IP addresses and manipulate non-encrypted traffic, which makes them vulnerable to malicious parties |
Can defend you against Distributed Denial-of-Service (DDoS) attacks | Failure in the one domain can bring down all front-end ones |
Distributes traffic across multiple servers and prevents overloading on a single server | Consumes additional network resources and processing power |
Improves website performance by serving content from the local cache | Causes everything to stop when there’s no access to the backend server |
Can decrypt encrypted data and reduce the server load | |
Routes requests to the nearest servers geographically, which minimizes access time |
Final Thoughts
Setting up your reverse proxy servers comes with numerous benefits. It can significantly improve your website’s security, scalability, and performance.
Nginx and Apache are among the most commonly used reverse proxy software. They are both reliable and easy to set up.
The first step in successfully setting up a reverse proxy is choosing the appropriate reverse proxy software. Tailor the settings according to your needs and manage incoming requests to your backend servers effectively.
FAQs
-
Does DNS act as a reverse proxy server?
A reverse proxy directs incoming requests to a server through Domain Name System (DNS) configuration.
-
Is Cloudflare a reverse proxy?
Yes. Cloudflare is a reverse proxy service that safeguards websites, enhances performance, and prevents malicious attacks.
Sources
Timeline Of The Article
By Raj Vardhman
Raj Vardhman is a tech expert and the Chief Tech Strategist at TechJury.net, where he leads the research-driven analysis and testing of various technology products and services. Raj has extensive tech industry experience and contributed to various software, cybersecurity, and artificial intelligence publications. With his insights and expertise in emerging technologies, Raj aims to help businesses and individuals make informed decisions regarding utilizing technology. When he's not working, he enjoys reading about the latest tech advancements and spending time with his family.