İçeriğe geç
Guides 2 dk okuma 885 görüntülenme

Apache as Reverse Proxy

Master Apache mod_proxy to set up a reverse proxy. This guide covers essential configuration, load balancing, and security best practices.

Apache as Reverse Proxy

Apache can function as a reverse proxy, forwarding client requests to backend servers and returning their responses, by utilizing the mod_proxy module and its related sub-modules.

A reverse proxy acts as an intermediary for client requests, directing them to one or more internal backend servers. It presents a unified interface to the internet while concealing the internal network architecture. Benefits include enhanced security, load balancing, SSL/TLS termination, caching, and simplified backend management.

Enabling mod_proxy

To configure Apache as a reverse proxy, the core mod_proxy module and specific sub-modules must be enabled. These modules provide different protocol support and features.

Essential modules:

  • mod_proxy: The core proxy module.
  • mod_proxy_http: For proxying HTTP and HTTPS traffic.
  • mod_proxy_balancer: Required for load balancing across multiple backend servers.
  • mod_proxy_wstunnel: For WebSocket proxying.
  • mod_ssl: If Apache will handle SSL/TLS termination for client connections.

Enable modules using the a2enmod command on Debian/Ubuntu-based systems, or by uncommenting LoadModule directives in httpd.conf on CentOS/RHEL-based systems:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod proxy_wstunnel
sudo a2enmod ssl
sudo systemctl restart apache2

Basic HTTP Reverse Proxy Configuration

The fundamental directives for a reverse proxy are ProxyPass and ProxyPassReverse. Configuration is typically placed within a <VirtualHost> block or directly in httpd.conf.

<VirtualHost *:80>
    ServerName yourdomain.com
    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
        Require all granted
    </Proxy>

    # Proxy all requests for /app to a backend server
    ProxyPass /app http://backend-app-server:8080/app
    ProxyPassReverse /app http://backend-app-server:8080/app

    # Proxy all requests for the root path / to another backend
    ProxyPass / http://backend-web-server:8000/
    ProxyPassReverse / http://backend-web-server:8000/

    # For SSL/TLS termination at Apache, and forwarding HTTP to backend
    # RequestHeader set X-Forwarded-Proto "https"
</VirtualHost>

Key Directives

  • ProxyRequests Off: This is critical. It disables Apache's forward proxy capabilities, preventing it from acting as an open proxy, which is a significant security risk. For a reverse proxy, this directive should always be set to Off.
  • ProxyPreserveHost On: This directive ensures that the original Host header from the client request is passed to the backend server. If Off, the Host header will be set to the hostname and port of the backend server.
  • ProxyPass [path] [url]: Maps a local URL path (path) to a backend URL (url). Apache intercepts requests matching path and forwards them to url.
    • Example: ProxyPass /app http://backend-app-server:8080/app means a request to http://yourdomain.com/app/page.html is forwarded to http://backend-app-server:8080/app/page.html.
  • ProxyPassReverse [path] [url]: Rewrites Location, Content-Location, and URI headers in HTTP responses from the backend server. This ensures that redirects or links generated by the backend point back to the public-facing proxy URL, preventing clients from being exposed to internal URLs.
  • <Proxy *>: Defines access control for the proxy itself. Require all granted permits all clients to use the proxy. For tighter security, specific IP addresses or networks can be allowed.

Advanced mod_proxy Features

Load Balancing

mod_proxy_balancer allows distributing incoming requests across multiple backend servers, enhancing availability and scalability.

<VirtualHost *:80>
    ServerName app.yourdomain.com
    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy balancer://mycluster>
        BalancerMember http://backend1.internal:8080 route=1 loadfactor=10
        BalancerMember http://backend2.internal:8080 route=2 loadfactor=10
        # Optional: ProxySet for specific balancer settings
        ProxySet lbmethod=byrequests stickysession=JSESSIONID nofailover=Off
        # For session stickiness, the backend must set a cookie like JSESSIONID
    </Proxy>

    ProxyPass / balancer://mycluster/
    ProxyPassReverse / balancer://mycluster/

    <Location "/balancer-manager">
        SetHandler balancer-manager
        Require ip 192.168.1.0/24 # Restrict access to internal network
    </Location>
</VirtualHost>
BalancerMember Attributes

| Attribute | Description

Güncellendi: 04.03.2026
Kategoriye dön

Bunları da okuyun

Guides 2 dk

Nike SNKRS için Proxy: Sınırlı Sürümler ve Çoklu Katılım

Nike SNKRS'ta birden fazla hesapla çekilişlere katılmak, IP limitlerini aşmak ve ban yemeden sınırlı sürümleri kapmak için residential veya mobil proxy kullanın. Hangi türü seçmeli ve nasıl kurmalı.

Guides 2 dk

iPhone'da Proxy Nasıl Kurulur (Wi-Fi ve SOCKS5)

iPhone'da proxy'yi yerleşik Wi-Fi ayarlarından (HTTP/HTTPS) veya SOCKS5 ile hücresel kapsama için Shadowrocket gibi bir uygulamayla kurun. Adım adım iOS kurulumu ve bilinmesi gereken kısıtlar.

Guides 3 dk

Tinder için proxy: çoklu hesap ve ban'lerden kaçınma

Birden fazla profil işletmek ve IP shadowban'lerinden kaçınmak için Tinder'da mobil veya residential proxy kullanın. Mobilin neden kazandığı, kurulumu ve proxy'nin şehri neden değiştirmediği.

Guides 2 dk

StockX için proxy: fiyat takibi ve hesap yönetimi

StockX'te fiyatları izlemek, birden fazla hesap çalıştırmak ve drop'ları yasaklanmadan kapmak için residential, ISP veya mobil proxy kullanın. Hangi türü seçeceğinizi ve nasıl kuracağınızı anlatıyoruz.

Guides 3 dk

OpenAI API için Proxy: Erişim, Hız Limitleri ve Kurulum

OpenAI API'yi residential veya ISP proxy üzerinden yönlendirerek desteklenen bölgelere erişin, 429 hız limitlerinden kaçının ve hesapları izole edin. Hangi proxy'yi seçmeli ve Python kurulum örnekleri.

Guides 1 dk

E2E testleri için Cypress'te proxy kurulumu

Cypress'te proxy kurulumu: HTTP_PROXY değişkenleri, cy-proxy-middleware ve coğrafi konuma bağlı içeriğin test edilmesi.

Proxy'lerimizi deneyin

100+ ülkede 20,000+ proxy

support_agent
GProxy Support
Usually replies within minutes
Hi there!
Send us a message and we'll reply as soon as possible.