Set Up Proxy_pass Apache with CloudPanel for Server Traffic

Set Up Proxy_pass Apache with CloudPanel for Server Traffic

Want to manage your server’s traffic better? Proxy_pass Apache allows Apache to work as a reverse proxy. It helps manage requests with efficiency. CloudPanel runs on NGINX by default and does not come with Apache. You can use Apache as a backend, but it requires a separate installation.

This tutorial shows how to set up Apache as a backend.

Key Takeaways

  • Apache's Proxy_pass forwards client requests to backend servers, ensuring efficient traffic management.

  • Before configuring Proxy_pass Apache, confirm your system meets all requirements.

  • You must enable the correct Apache modules for Proxy_pass to function as intended.

  • CloudPanel lets you set up NGINX reverse proxy options.

  • Fixing common issues with Proxy_pass Apache keeps your setup operational.

  • Stay updated to get the most from Proxy_pass with Apache.

What is Proxy_pass in Apache and Why Is It Used?

Proxy_pass is a directive in Apache HTTP Server. It forwards client requests to a backend server, acting as a reverse proxy.

Proxy_pass sends client requests to another server. People know this server as a backend or origin application server. When someone visits a URL, Apache pulls the content from the backend.

CloudPanel's easy-to-use dashboard makes setting up NGINX simple. You can forward traffic to backend servers like Apache with one click. It also offers SSL/TLS, IP blocking, and load balancing to boost security and performance.

Why Use Proxy_pass?

Proxy_pass is valuable for several reasons:

  • Backend Protection: It hides backend web servers from direct access. This reduces exposure to the public internet.

  • Load Balancer: It spreads requests over many backend servers. This helps improve speed and uptime.

  • Centralized Access: It lets many apps run from one domain or IP. This simplifies DNS and SSL setup, especially for virtual hosts.

  • SSL Termination: The Apache HTTP Server manages SSL encryption. It sends unencrypted traffic to backend servers that do not support SSL.

  • Caching and Compression: It provides caching and compression tools that backend servers lack.

  • Legacy Integration: It links old systems to new web setups. This keeps them separate.

7 System Requirements Before Configuring Proxy_pass Apache

1. Apache Installation

Apache set up on port 8080 for reverse proxy use

You must have the Apache web server installed on your system. Install Apache before setting up Proxy_pass.

2. Required Apache Modules

To configure Proxy_pass, you need to activate several Apache modules:

  • mod_proxy extension: The core module.

  • mod_proxy_http: For HTTP proxying.

  • mod_proxy_balancer: For load balancing if needed.

  • mod_lbmethod_byrequests: A load balancing method.

  • mod_rewrite: For URL rewriting (optional but helpful).

  • mod_deflate: For compression (optional).

  • mod_headers: To manage headers (optional).

  • mod_proxy_connect, mod_proxy_html, mod_ssl, slotmem_shm: Needed for advanced cases like:

    1. HTTPS proxying

    2. HTML rewriting.

Note: If Apache is a backend server, you do not need to turn on proxy modules, like mod_proxy_balancer.

3. Backend (Origin) Servers

You need at least one origin server. It should run and be reachable from your Apache web server. Examples include Apache Tomcat or Node.js. The reverse proxy server forwards requests to this backend.

4. Operating System and Hardware

OS and hardware needed for Apache with CloudPanel

Apache HTTP Server and Proxy_pass run on many Unix-like systems, including:

  • Linux

  • BSD

  • macOS

  • Windows.

A server with 1 CPU core and 512 MB of RAM is enough for most setups. High traffic or complex configurations need more resources.

5. Network and Firewall Configuration

Your Apache reverse proxy must connect to backend servers on ports like:

  • 8080

  • 8081.

Ensure ports 80 and 443 are open on your firewall.

6. Server Protection

Do not enable reverse proxies (ProxyRequests On) unless you protect your server. Open proxies pose significant risks. Apply access controls to maintain your reverse proxy’s safety.

7. Configuration Files

  • You need access to Apache’s configuration files, such as: httpd.conf or virtual host files in /etc/apache2/sites-available/.
  • To add the Proxy_pass directive and configure your Apache reverse proxy.

3 Steps to Activate Required Apache Modules

  • On Ubuntu/Debian Systems

Step 1: Enable Modules

Run this command to activate core and optional modules:

  • sudo a2enmod proxy

  • sudo a2enmod proxy_http

  • sudo a2enmod proxy_balancer

  • sudo a2enmod lbmethod_byrequests

They support proxying and HTTP. It also includes balancing loads, rewriting URLs, and compressing data. They provide SSL and HTML features.

Step 2: Restrict Apache

Apply changes:

sudo systemctl restart apache2.

  • On CentOS/Red Hat Systems

Step 1: Check Enabled Modules

  • Run httpd \-M to check for:

    1. proxy\_module

    2. proxy\_http\_module

    3. proxy\_balancer\_module

    4. lbmethod\_byrequests\_module

  • If missing, edit /etc/httpd/conf.modules.d/00-proxy.conf and uncomment:

    1. LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module

    2. modules/mod_proxy_http.so LoadModule proxy_balancer_module

    3. modules/mod_proxy_balancer.so LoadModulelbmethod_byrequests_module

    4. modules/mod_lbmethod_byrequests.so

  • Save and exit.

Step 2: Restart Apache

Run this command:

sudo systemctl restart httpd.

5 Steps to Configure Proxy_pass with CloudPanel

Step 1: Install and Start Apache

  • Install Apache on your server:

    sudo apt install apache2

  • Enable and start Apache so it runs on boot:

    sudo systemctl enable apache2 && sudo systemctl start apache2

  • Change Apache’s port:

    1. Open the config file: /etc/apache2/ports.conf

    2. Find Listen 80 and change it to: Listen 8080

  • Update your Apache site config to listen on port 8080.

Step 2: Create an Apache Virtual Host

  • Make a virtual host file for your domain: /etc/apache2/sites-available/your-domain.com.conf

  • Example content: <VirtualHost *:8080> ServerName your-domain.com DocumentRoot /var/www/your-domain

    \<Directory /var/www/your-domain\>  
        AllowOverride All  
        Options Indexes FollowSymLinks  
    \</Directory\>  
    
    ErrorLog ${APACHE\_LOG\_DIR}/your-domain-error.log  
    CustomLog ${APACHE\_LOG\_DIR}/your-domain-access.log combined  
    

    </VirtualHost>

  • Create the folder where your site files will go: sudo mkdir \-p /var/www/your-domain

  • Enable and restart Apache for changes: sudo a2ensite [your-domain.com](http://your-domain.com)\ sudo systemctl restart apache2

Step 3: Use Proxy_pass Apache with NGINX in CloudPanel

  • Log in to your CloudPanel dashboard.

  • Go to the Sites section, select your domain, and choose “Create a Reverse Proxy.”

  • CloudPanel requires you to assign a system user during site creation. This user owns the web root directory and isolates each site’s configuration.

  • Enter the:

    1. Domain Name

    2. Reverse Proxy URL.

  • Save the changes.

  • CloudPanel will configure NGINX to forward traffic to Apache, generating a configuration like:

    server {

    listen 80;
    
          server\_name your-domain.com;
    

    location / {

      proxy\_pass http://127.0.0.1:8080;
    
      proxy\_set\_header Host $host;
    
      proxy\_set\_header X-Real-IP $remote\_addr;
    
      proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;
    
      proxy\_set\_header X-Forwarded-Proto $scheme;
    

    }

         }
    
  • Restart NGINX via CloudPanel.

Note: If your backend uses WebSockets, add headers like Upgrade and Connection.

Step 4: Set Up SSL (Optional)

  • In CloudPanel, go to the SSL/TLS.

  • Click “Add SSL Certificate”. Use a free Let’s Encrypt certificate.

  • You can upload your certificate and private key.

  • Save the changes.

  • CloudPanel redirects HTTP to HTTPS without user intervention. It also handles redirects for both www and non-www versions.

  • Automatic renewal of SSL certificates occurs through Let’s Encrypt.

  • CloudPanel will set up NGINX for HTTPS. It will update the config to add a block like:

    server {

    listen 443 ssl;
    
    server\_name your-domain.com;
    
    ssl\_certificate /path/to/your-domain.crt;
    

    ssl_certificate_key /path/to/your-domain.key;

    location / {

      proxy\_pass http://127.0.0.1:8080;
    
      proxy\_set\_header Host $host;
    
      proxy\_set\_header X-Real-IP $remote\_addr;
    
      proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;
    
      proxy\_set\_header X-Forwarded-Proto $scheme;
    

    }

        }
    
  • Restart NGINX through CloudPanel to apply the SSL configuration.

  • Verify HTTPS by accessing https://your-domain.com in a browser.

Step 5: Test Everything

  • Open your domain in a web browser to check if it’s working.

  • If something does not load, check the logs:

    1. Apache logs: /var/log/apache2/

    2. NGINX logs: /var/log/nginx/

Load Balancing with CloudPanel and Proxy_pass Apache

CloudPanel’s NGINX reverse proxy helps share traffic among many Apache backend servers. This load balancing boosts performance and reliability. Apache can also use Proxy_pass with mod_proxy_balancer to balance traffic to extra backends. Below are the steps to set it up:

Step 1: Set Up Many Apache Backends

  • Ensure you have at least two Apache servers running, for example, on:

    1. 127.0.0.1:8080

    2. 127.0.0.1:8081

  • Install Apache and set up virtual hosts for each server as described earlier.

Step 2: Configure NGINX Load Balancing in CloudPanel

  • Log in to your CloudPanel dashboard.

  • Go to the Sites section, select your domain, and choose “Create a Reverse Proxy.”

  • Enter the:

    1. Domain Name

    2. Multiple Reverse Proxy URLs, for example:

  • [http://127.0.0.1:8080](http://127.0.0.1:8080)

  • [http://127.0.0.1:8081](http://127.0.0.1:8081).

  • For backend URLs, check CloudPanel’s documentation.

  • The version shows the accepted syntax. This includes comma-separated values and JSON array format.

  • Save the changes.

  • CloudPanel will configure NGINX to balance traffic, generating a configuration like:

    server {

    listen 80;
    

    server_name your-domain.com;

    location / {

      proxy\_pass http://backend\_pool;
    
      proxy\_set\_header Host $host;
    
      proxy\_set\_header X-Real-IP $remote\_addr;
    
      proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;
    
      proxy\_set\_header X-Forwarded-Proto $scheme;
    

    }

}

upstream backend_pool {

server 127.0.0.1:8080;

server 127.0.0.1:8081;

}

  • Restart NGINX through CloudPanel.

Step 3: Optional Apache Load Balancing

  • If your Apache server proxies to extra backends, enable mod_proxy_balancer:

    sudo a2enmod proxy\_balancer lbmethod\_byrequests

  • Edit your Apache virtual host file:

    e.g., /etc/apache2/sites-available/your-domain.com.conf):

    <VirtualHost *:8080>

    ServerName your-domain.com
    
    \<Proxy balancer://mycluster\>
    
        BalancerMember http://backend1.example.com:8080
    
        BalancerMember http://backend2.example.com:8080
    
        ProxySet lbmethod=byrequests
    
    \</Proxy\>
    
    Proxy\_pass / balancer://mycluster/
    
    Proxy\_passReverse / balancer://mycluster/
    

    </VirtualHost>

  • Restart Apache: `sudo systemctl restart apache2`.

Step 4: Test Load Balancing

  • Access your domain (e.g., http://your-domain.com).

  • Refresh often to confirm that the system distributes traffic across the Apache backends.

  • Check:

    1. NGINX logs (/var/log/NGINX/)

    2. Apache logs (/var/log/apache2/) for verification.

7 Common Problems and Fixes When Using Proxy_pass Apache

1. 404 Not Found Errors

Fix 404 errors in Apache reverse proxy

Problem: You get a 404 error for some requests, even though the backend has the correct files.

Cause: This happens when Proxy_pass only targets a path like:

/sample/, but the backend site uses full paths like /p/login/. Apache searches for these files on its local system but cannot locate them.

Fix: Make sure your Proxy_pass rules include all the paths your backend uses. Or, update the backend to use relative paths that work with your proxy setup.

Note: Proxy_passReverse only changes certain headers like Location. It does not rewrite links inside your HTML or scripts.

2. 400 Bad Request with SSL

Problem: You see a “400 Bad Request” error when using SSL with Proxy_pass.

Causes and Fixes:

  • SSL Certificate Issues: Correcting the SSLCertificateFile and SSLCertificateKeyFile settings.

  • SSL VirtualHost Setup: Your SSL VirtualHost should be set on port 443. Include all proxy-related directives.

  • Missing Host Header: Turn on ProxyPreserveHost On. It helps send the original host header to the backend.

  • Connection Errors: You can reach the backend server using the correct port.

  • Request Size Problems: If the system blocks large requests, raise the LimitRequestBody setting.

  • SSL Settings Conflict: Confirm that both ends' SSL/TLS protocols are compatible.

3. Proxy_pass and Proxy_passMatch Overlap

Problem: One rule can overshadow another. This can cause the system to route traffic in the wrong direction.

Cause: A general rule, like /, can precede Apache before it gets to more specific rules.

Fix: Order your Proxy_pass and Proxy_passMatch rules with precision. Put the specific ones first.

4. URL Normalization Issues

Problem: Apache changes parts of the URL, breaking the backend's handling.

Fix: Use the nocanon option with your Proxy_pass rule. This keeps the original format of the URL when sending it to the backend.

5. Backend Not Handling Proxied Requests

Problem: The backend server does not know it’s behind a proxy. This causes redirect or link errors.

Fix: Turn on ProxyPreserveHost On to send the original Host header. Set up your backend server to detect if it is behind a proxy. Use the right external URL.

6. Misconfigured Virtual Hosts

Problem: Apache serves the wrong site, or the default one loads instead of the correct one.

Fix: Make sure your VirtualHost for the proxied domain loads before the default site. If you do not need the default, disable it to avoid conflicts.

7. Debugging and Logs

Tip: Check Apache logs for errors in:

  • /var/log/apache2/error.log (Ubuntu/Debian) or

  • /var/log/httpd/error_log (CentOS/Red Hat.

Look for entries like:

  • [error] AH00957: attempt to connect to 127.0.0.1:8080 failed (backend unreachable) or
  • [error] AH01114: Invalid URI in request (URL issues).

To fix WebSocket issues in apps, check that your CloudPanel reverse proxy is set up like this:

  • proxy_set_header Upgrade $http_upgrade;

  • proxy_set_header Connection "upgrade".

5 Latest Developments in Proxy_pass Apache

1. Enhanced Security Practices

Secure Apache reverse proxy settings

  • Zero-Trust Security: Use Proxy\_pass with CloudPanel’s IP limits and basic authentication. This ensures secure access control, in line with the zero-trust trends for 2025.

  • TLS/SSL Enhancements: Use SSLProxyEngine On with valid certificates for secure backend connections. It is important for modern hosting.

2. Advanced Load Balancing and Failover

  • Dynamic Workers: mod\_proxy\_balancer supports many backends with health checks for seamless failover.

  • Ping Parameter: Tests backend availability to reduce downtime.

3. Container Integration

  • Docker Support: Proxy\_pass works with Docker backends through CloudPanel’s NGINX reverse proxy. It supports microservices and apps, such as Uptime Kuma.

  • Unix Socket Proxying: With Apache 2.4.7, you can now use Unix sockets. This speeds up local connections, especially in container setups.

4. Header and Cookie Management

  • Header Preservation: ProxyPreserveHost keeps the right domain for backends. It is important for apps such as WordPress.

  • Cookie Rewriting: Proxy\_passReverseCookieDomain and Proxy\_passReverseCookiePath manage session cookies for web apps.

5. Hybrid Proxy Solutions

NGINX and HAProxy Integration: Use Apache Proxy\_pass with CloudPanel’s NGINX or HAProxy. The setup boosts load balancing and performance.

FAQs

1. What does Proxy_pass do in Apache?

Proxy_pass tells Apache to send web traffic to another server. It hides the real source of the content. The user still sees the same site address. It helps serve many apps from one site.

2. Is Proxy_pass the same as a redirect?

A redirect sends the browser to a new URL. Proxy_pass keeps the URL the same but shows content from another place. Users do not see the change.

3. Do I need to install anything to use Proxy_pass?

You do not need to install anything new. Apache already has the needed modules. Enable mod_proxy and mod_proxy_http. These let you set up proxy rules.

4. Can I use Proxy_pass with CloudPanel?

CloudPanel lets you set up a reverse proxy with NGINX. It can send traffic to an Apache backend using Proxy_pass. You can install the NGINX reverse proxy using the CloudPanel dashboard. This makes it simple for beginners.

5. What is Proxy_passReverse used for?

Proxy_passReverse rewrites headers in the response. It helps fix links and redirects. Without it, users may land on the wrong pages. It’s key for clean link handling.

Summary

Proxy_pass sends client requests to another server behind the scenes. It acts like a middleman, forwarding traffic from Apache to backend servers. This helps speed up your site and balance the load across servers. Consider the following common issues you might face:

  • Some requests show a 404 error even though the backend has the files.

  • SSL setup problems can cause a 400 Bad Request error when using Proxy_pass.

  • Broad Proxy_pass rules can block more specific Proxy_passMatch rules from working.

  • Wrong virtual host settings can cause the server to load the wrong site or the default one.

Want to simplify your server with Proxy_pass Apache? Try CloudPanel Free Hosting today to simplify your server setup with Apache.

Nikita Parmar
Nikita Parmar
Technical Writer

Nikita is a skilled writer who simplifies complex ideas for the CloudPanel audience. She creates SEO-friendly and engaging posts that help readers understand and use CloudPanel. She consistently delivers clear, informative, and audience-focused content.


Deploy CloudPanel For Free! Get Started For Free!