• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Apache for Newbie: Set up mod_proxy

December 21, 2023

Apache for Newbie: Set up mod_proxy

Apache is one of the most popular web servers in the world, known for its flexibility and robustness. It allows you to host websites and applications on your server, making it accessible to users across the globe. One of the powerful features of Apache is mod_proxy, which enables you to set up a reverse proxy server. In this article, we will explore how to set up mod_proxy on Apache for beginners.

What is mod_proxy?

Mod_proxy is an Apache module that provides proxying capabilities. It allows Apache to act as a gateway or intermediary between clients and backend servers. With mod_proxy, you can forward requests from clients to backend servers, retrieve the responses, and send them back to the clients. This is useful in various scenarios, such as load balancing, caching, and content filtering.

Enabling mod_proxy

To set up mod_proxy, you need to enable the module in Apache. Here are the steps:

  1. Connect to your server via SSH or any other remote access method.
  2. Open the Apache configuration file using a text editor. The file is usually located at /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf.
  3. Search for the line that starts with #LoadModule proxy_module modules/mod_proxy.so. Remove the # at the beginning of the line to uncomment it.
  4. Save the changes and exit the text editor.
  5. Restart Apache for the changes to take effect. The command to restart Apache varies depending on your operating system. For example, on Ubuntu, you can use sudo service apache2 restart.

Configuring mod_proxy

Once mod_proxy is enabled, you can start configuring it to proxy requests to backend servers. Here’s an example configuration:

<VirtualHost *:80>
    ServerName example.com
    ProxyPass / http://backend-server/
    ProxyPassReverse / http://backend-server/
</VirtualHost>

In the above configuration, replace example.com with your domain name and backend-server with the IP address or hostname of your backend server. The ProxyPass directive specifies the URL path to proxy, while the ProxyPassReverse directive rewrites the response headers to match the client’s URL.

You can also configure mod_proxy to load balance requests across multiple backend servers. Here’s an example:

<VirtualHost *:80>
    ServerName example.com
    ProxyPass / balancer://mycluster/
    ProxyPassReverse / balancer://mycluster/
    ProxyPreserveHost On

    
        BalancerMember http://backend-server1/
        BalancerMember http://backend-server2/
    
</VirtualHost>

In the above configuration, replace backend-server1 and backend-server2 with the IP addresses or hostnames of your backend servers. The ProxyPreserveHost directive preserves the original Host header in the request, allowing the backend servers to correctly handle virtual hosts.

Conclusion

Setting up mod_proxy on Apache allows you to leverage its powerful proxying capabilities. Whether you need to forward requests to backend servers, load balance across multiple servers, or implement caching, mod_proxy has got you covered. By following the steps and examples provided in this article, even beginners can easily configure mod_proxy and enhance their Apache server’s functionality.

For more information about VPS hosting and how it can benefit your website or application, check out Server.HK. Our VPS solutions are top-notch and designed to meet your specific hosting needs.

Recent Posts

  • How to Set Up Nginx on CentOS Stream for High-Performance Web Hosting
  • CentOS Stream Explained: Key Differences from CentOS Linux
  • How to Configure FirewallD in CentOS Stream: From Essential to Production-Grade
  • Installing Docker on CentOS: A Practical Setup Guide (CentOS Stream 9/10 – 2026)
  • How to Secure a CentOS Server: 15 Essential Hardening Techniques (CentOS Stream 9/10 – 2026)

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot