• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

mod_proxy Installation and Configuration on Apache

mod_proxy installation on Apache

Introduction

mod_proxy is a proxy/gateway for the Apache server. It allows you to direct Apache requests to other sites and/or ports within the web server. It can also support load balancing algorithms as well. This guide assumes you already have Apache 2.2 installed from source to build the modules.  To read more about it you can review the module documentation on Apache’s mod_proxy page

Install mod_proxy

Go to the source directory of the Apache installation

cd /usr/src/httpd-2.2.24

Replace the path with where you downloaded the Apache installation.

Reconfigure the existing apache configuring appending the mod_proxy lines

./config-nice --enable-proxy=shared

Rebuild Apache:

make

Install the new Apache

make install

Once you have done that you will want to edit the Apache Configuration to load the modules

vim /etc/httpd/conf/httpd.conf

Add the following modules and save the file

LoadModule proxy_module lib/apache/mod_proxy.so
LoadModule proxy_http_module lib/apache/mod_proxy_http.so
LoadModule proxy_balancer_module lib/apache/mod_proxy_balancer.so
LoadModule proxy_connect_module lib/apache/mod_proxy_connect.so
LoadModule proxy_ftp_module lib/apache/mod_proxy_ftp.so
LoadModule proxy_scgi_module lib/apache/mod_proxy_scgi.so
LoadModule proxy_ajp_module lib/apache/mod_proxy_ajp.so

Restart Apache to load them

service httpd restart

Configure mod_proxy

Once mod_proxy is loaded you can now configure it to work on domains.

Reverse Proxy Configuration:

<VirtualHost 192.168.1.10:80>
ServerName  domain.com
ProxyPreserveHost On
 ProxyPass / http://127.0.0.1:8080/
 ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>

This example will pass requests to the same server on port :8080. You could utilize this to pass requests do a different application, java, ruby, tomcat etc.

SSL Reverse Proxy Configuration:

<VirtualHost 192.168.1.10:443>
ServerName  domain.com
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
SSLCertificateFile /path/to/certificate.crt
SSLCertificateKeyFile /path/to/certificate.key
SSLCertificateChainFile /path/to/chainfile.crt
</VirtualHost>

This configuration is almost identical except you are setting the variables for SSL Configuration.

Load Balancing Proxy Configuration:

This allows you to utilize multiple back-end servers with a single Apache front-end load balancing the requests.

<Proxy balancer://cluster>
BalancerMember http://192.168.1.10:8080/
BalancerMember http://192.168.1.11:8080/
</Proxy>

<VirtualHost 192.168.1.10:80>
ServerName  domain.com
ProxyPass / balancer://cluster
</VirtualHost>

You would add in the IP addresses for each of the members to be load balanced  as BalancerMember.

Once you have added the new configurations, you go ahead and restart apache again to load in the new mod_proxy settings

service httpd restart
May 22, 2017LinuxAdmin.io
5 1 vote
Article Rating
mod_fastcgi Installation on Apache 2.2How To Configure A Nginx Reverse Proxy With Apache
You Might Also Like
 
How To Setup SSH Key Authentication
 
OSSEC Intrusion Detection Installation On Centos 7
Subscribe
Notify of
guest

guest

0 Comments
Inline Feedbacks
View all comments
8 years ago Apache, Web Hosting 7,295
Recent Posts
  • Configuring Firewalld to Work Seamlessly with Docker on CentOS
  • Mastering NGINX Tuning: Optimizing Web Server Performance
  • Exploring eBPF: Revolutionizing Network and System Monitoring
  • Kubernetes: Installation and Overview on CentOS 8
  • Install Docker on Centos 8
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
76,148 views
Zend Opcache
Setup and Optimize Zend OpCache
47,105 views
Install ffmpeg
FFMpeg Install On CentOS 7
21,675 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz