• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How to Configure Apache as Reverse Proxy (Ubuntu, Cloud Server)

By Abhishek Ghosh February 10, 2017 8:01 am Updated on February 10, 2017

How to Configure Apache as Reverse Proxy (Ubuntu, Cloud Server)

Advertisement

Normally these days we use Nginx as reverse proxy. Like, in an old guide we have shown how to use Nginx reverse proxy to add an IPv6 address to IPv4 only dedicated server. Also we provided configuration of such for HSTS website. We actually can use Apache web server as reverse proxy. Here is How to Configure Apache as Reverse Proxy on Single Cloud Server Instance Running Ubuntu 16.04 For IPv4. We will use some cloud server like VPSDime $7 per month 6 GB OpenVZ instance for this work. For very small need, we can use 1GB RAM at 1 Euro Per Month Aruba Cloud VMWare instance. We will set up Apache as a basic reverse proxy using the mod_proxy extension to redirect the incoming connections to one or several backend servers.

How to Configure Apache as Reverse Proxy Ubuntu, Cloud Server

 

Required Modules to Configure Apache as Reverse Proxy

 

The modules that are needed to use Apache as a reverse proxy includes :

  1. mod_proxy : the core proxy module Apache module for redirecting connections
  2. mod_proxy_http : adds support for proxying HTTP and HTTPS connections.
  3. mod_proxy_balancer : adds load balancing features.
  4. mod_lbmethod_byrequests : adds load balancing features.
  5. mod_proxy_ftp : This handles fetching documents with FTP.
  6. mod_proxy_connect : This handles the CONNECT method for secure tunnelling.
  7. mod_proxy_ajp : This handles the AJP protocol for Tomcat like backend servers.
  8. mod_proxy_html:  This rewrites HTML links into a proxy’s address space.
  9. mod_xml2enc : This supports internationalisation behalf of mod_proxy_html.
  10. mod_headers: This modifies HTTP request and response headers.
  11. mod_deflate: Negotiates compression with clients and backends.
  12. mod_cache : To enable caching.
  13. mod_disk_cache : To enable caching.
  14. mod_mem_cache : To enable caching.

 

How to Configure Apache as Reverse Proxy

 

First update and upgrade :

Advertisement

---

Vim
1
apt update -y

Vim
1
apt upgrade -y

Now, we will install Apache on our server :

Vim
1
apt install apache2 -y

Once Apache has been installed, we need to start the Apache service, configure it to start automatically restart on reboot. Open :

Vim
1
2
sudo /etc/init.d/apache2 start
sudo update-rc.d apache2 defaults

We have to install mod_proxy and dependencies :

Vim
1
apt install libapache2-mod-proxy-html libxml2-dev build-essential -y

Run the below command to get the list of available modules:

Vim
1
sudo a2enmod

We need to run commands to enable the modules we need, one by one :

Vim
1
2
3
4
5
6
7
8
9
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod headers
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html

Apache default configuration file is usually 000-default.conf, we can create our own virtual host file at /etc/apache2/sites-available location :

Vim
1
2
3
sudo a2dissite 000-default
touch /etc/apache2/sites-available/proxy-http
nano /etc/apache2/sites-available/proxy-http

Now, add something like this on that /etc/apache2/sites-available/proxy-http file :

/etc/apache2/sites-available/proxy-http
Vim
1
2
3
4
5
6
7
8
  ServerAdmin admin@example.com
  DocumentRoot /var/www/
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  ProxyPreserveHost On
  ProxyPass / http://server-ip-address:8080/
  ProxyPassReverse / http://server-ip-address:8080/
  ServerName example.com

Save and close the file. Enable new virtual host file:

Vim
1
sudo a2ensite proxy-http

We may also need to direct Apache to listen on port 8080. “May”, as it depends. That can be done by editing the ports.conf file:

Vim
1
nano /etc/apache2/ports.conf

Directive will be :

Vim
1
Listen 8080

If you change, you need to restart :

Vim
1
sudo /etc/init.d/apache2 restart

In the above change of port case, http://i.p.a.d.d.r.e.ss:80 will show the application which is running on http://i.p.a.d.d.r.e.ss:8080. If we want to enable SSL support, then we will need to enable the SSL module first.

Vim
1
2
sudo a2enmod ssl
sudo /etc/init.d/apache2 restart

Next, you will need to use Let’s Encrypt certificate in the way we have shown for Nginx in different guide.
We can copy all the certificate files to the /etc/apache2/ssl directory. We will create new virtual host file named proxy-https :

Vim
1
nano /etc/apache2/sites-available/proxy-https

Here is example config :

Vim
1
2
3
4
5
6
7
8
9
10
11
        ServerAdmin admin@example.com
        DocumentRoot /var/www/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/ca.crt
        SSLCertificateKeyFile /etc/apache2/ssl/ca.key
        ProxyPreserveHost On
        ProxyPass /var/www/ http://server-ip-address:8080/
        ProxyPassReverse /var/www/ http://server-ip-address:8080/
        ServerName example.com

Save and close the file. Enable new virtual host file:

Vim
1
2
sudo a2ensite proxy-https
sudo /etc/init.d/apache2 restart

There is huge documentation on Apache’s site :

Vim
1
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

We provided quite basic examples on how to configure Apache as reverse proxy, but possibly that is the critical part.

Tagged With apache as a reverse proxy server , apache reverse proxy change acl depends on conf , apache reverse proxy config , apache windows reverse proxy server setup , erse proxy load balance , paperuri:(b5ca0a1b9798d30ebec9e3469928d2a0) , reverse proxy apache on windows , ubuntu apache2 reverse proxy , Обратный прокси
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Configure Apache as Reverse Proxy (Ubuntu, Cloud Server)

  • Ubuntu 18.04 Apache Reverse Proxy, Loadbalancer Configuration Step by Step

    Apache Webserver Also Can Work as Loadbalancer. Here is Ubuntu 18.04 Apache Reverse Proxy, Loadbalancer Configuration Step by Step Guide.

  • Proxy Server and Reverse Proxy

    Proxy Server and Reverse Proxy Sound Quite Closer to Common Man. Here we have discussed these Two Different Communication interfaces in a Network.

  • How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS

    Here is Detailed Guide on How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS With Commands and Configurations For Most Secured Setup.

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy