• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

AI, Linux, Cloud and DevOps

  • Home
  • Resources
    • Learn Linux
    • Articles
  • My Projects & Work
    • My Nagios Plugin
    • My Dockerhub Repo
    • My WordPress plugins
    • My Github Repos
  • Facebook Page
  • Contact
  • Privacy Policy
  • About Me
You are here: Home / Apache / How to install mod_proxy and setup reverse proxy in Apache Ubuntu

How to install mod_proxy and setup reverse proxy in Apache Ubuntu

August 2, 2013 by Sharad Chhetri 12 Comments

How to install mod_proxy and setup reverse proxy in Apache Ubuntu

Today in this tutorial we will learn about installing apache proxy module and how to setup reverse proxy.
The module name is mod_proxy ,it is core module which supports Forward and Reverse Proxy settings in Apache WebServer. There are other modules also which is required in Apache webserver as per the requirement for example
mod_proxy_http, mod_proxy_ftp, mod_proxy_ajp, mod_proxy_balancer, and mod_proxy_connect

Reverse proxy is widely used to access the webserver which is behind the firewall.Reverse Proxy has the capability to load balance the request among the backend-server as well caching can also be done.Mainly, reverse proxies can be used simply to bring several servers into the same URL space.

For eg. lets see this scenario –

Scenario 1:
We have One Web server which has public ip address and DNS record means it can be accessible by using the url www.example.com or http://example.com
We have some internal webserver lets assume, internalwebserver1,internalwebserver2 and internalwebserver3. Internal web servers can not be access directly from public internet because they have private IP as well as they are behind the firewall. Means if someone try to access these internal server it will get error No such host.
But there are some important web application or webpages are serving from internal web server which is required to map with example.com .
So in this case what we will do we will setup the Reverse Proxy server. If any request come to main URL i.e example.com the Web Server will check which path is mapped to its internal web server in configuration file.

OK have this another Scenarios –

Scenario 2:
I have one OpenERP server which runs in port no. 8069 eg. http://openrp.example.com:8069 but I would like to open the website openerp.example.com in URL means port no. 80 bydefault. In this case also we can setup reverse proxy in single openerp server.

Install mod_proxy and setup reverse proxy in Apache Webserver

Follow the given below steps.
Note: In all given below example replace the value of ServerAdmin,ServerName & ServerAlias as per your server information

Step 1: Install the module

sudo apt-get install libapache2-mod-proxy-html

Step 2: Installing the dependency libxml2-dev

apt-get install libxml2-dev

Step 3: Load the module

a2enmod proxy proxy_http

Step 4: Create the Virtual Host in apache configuration file . If your configuration is located in conf.d you have to do changes in that file. I am giving example with default setting in Apache Webserver in Ubuntu

vi /etc/apache2/sites-enabled/000-default

Paste the below two lines within VirtualHost tag

ProxyPass /foo http://internalwebserver1.example.com/give/path/of-requested-location
ProxyPassReverse /foo http://internalwebserver1.example.com/give/path/of-requested-location

Lets see the configuration of my file,it will clear the doubt


        ServerAdmin sharad@example.com
        ServerName example.com
        ServerAlias example.com
       ProxyPass /foo http://internalwebserver1.example.com/files/webapp
       ProxyPassReverse /foo  http://internalwebserver1.example.com/files/webapp
    

Step 5: Now restart the apache

/etc/init.d/apache2 restart

Step 6: Now Openbrowser in client machine and check the website. Done

Now for Scenario 2:

Follow the all above given steps except in Step 4 you have to do below given setting
Below is the reference of my configuration file


        ServerAdmin sharad@example.com
        ServerName openerp.example.com
        ServerAlias openerp.example.com
       ProxyPass / http://openerp.example.com:8069
       ProxyPassReverse / http://openerp.example.com:8069
    


Restart the apache2 and open the browser and check it

/etc/init.d/apache2 restart

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • More
  • Print (Opens in new window) Print
  • Email a link to a friend (Opens in new window) Email
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon

Articles

Install osTicket ( Open source ticketing tool ) on Ubuntu 14.04 LTS
Installation of OpenERP 7.0 in Ubuntu
Install and setup multisite drupal on CentOS 6.5
How to install own git server with ssh and http access by using gitolite and gitweb in CentOS
How to install nginx webserver from source on CentOS and RHEL
How to install apache webserver in CentOS and Red Hat
How to install and remove Apache webserver in Ubuntu and Debian
Setup self signed SSL certificate for ghost blog on Nginx
check_openerp nagios plugin for openerp service
Setup self signed ssl certificate on Owncloud 6 in Ubuntu 14.04 LTS Server
Setup Master Slave Chroot BIND DNS in CentOS 6 or Red Hat 6
Install and configure transparent squid proxy server : RHEL/CentOS 6.x
Find installed and enabled apache module in Debian/Ubuntu
Install pagespeed module ( mod_pagespeed ) on Apache Web Server : CentOS / RHEL
Setup Owncloud 6 with self signed SSL certificate on Ubuntu 13.10

Filed Under: Apache, Articles Tagged With: apache

Reader Interactions

Comments

  1. Karl says

    June 21, 2016 at 10:41 am

    Which version of Ubuntu is this for? I tried with 16 and some of the required components fail

    Reply
    • sharad chhetri says

      June 21, 2016 at 4:24 pm

      Hello Karl,

      This is practically verified till Ubuntu 14.04 LTS server . Soon we will publish the tutorial on Ubuntu 16.06 LTS also.

      Regards
      Sharad

      Reply
  2. faycal says

    March 4, 2015 at 9:36 pm

    thank’s for yur example

    i when i do like this, i access to website without port and context name, but the css and javascript files doesnt work

    what must i add ?

    thank’s

    Reply
    • sharad chhetri says

      March 5, 2015 at 2:39 am

      Hello Faycal,

      It should work.
      Can you check with developers that does it require “CORS” on Apache or js/css files called from remote server then check the connectivity.

      Regards
      Sharad

      Reply
      • faycal says

        March 5, 2015 at 1:30 pm

        It’s my personnal projet, i’m the only developper.

        what’s “CORS” ? i’m using Ubuntu server 14.04 and apache 2

        Reply
        • sharad chhetri says

          March 5, 2015 at 4:01 pm

          Hello Faycal,

          May I see the code where you are using the style.css and js file.
          To keep it private , you can send email to admin@sharadchhetri.com

          Regards
          Sharad

          Reply
          • faycal says

            March 5, 2015 at 4:58 pm

            hello,

            i’ve sent an email with simple code

            thank’s

      • Imtiaz says

        May 26, 2015 at 2:27 pm

        I am facing same problem my page is not loaded just the page name is shown no CSS and java script loaded. When I access my application from CF VM Box it works fine but when accessing outsite the method u mentioned it gives me issue as mentioned above.

        Reply
  3. Don says

    January 15, 2015 at 3:46 pm

    Thanks for the great tutorial!
    I was able to forward openerp’s 8069 port to 80 except the CSS and images are blocked… Would you know how to fix this? Is it a permission issue?

    Reply
    • sharad chhetri says

      January 16, 2015 at 4:50 pm

      Hello,

      1. It may be permission issue.
      2. or the image url is not correct in code. May be image url still using port 8069 for eg.
      3. Recommend to install firbug on firefox and debug the issue once.

      Regards
      Sharad

      Reply
  4. Kumar says

    December 17, 2013 at 1:01 pm

    To load the module , below does not work..

    a2enmod mod_proxy mod_proxy_http

    Correct one is,

    a2enmod proxy proxy_http

    Reply
    • sharad chhetri says

      December 17, 2013 at 3:36 pm

      Thanks Kumar,

      I did typo by using mod as prefix(mod_proxy mod_proxy_http module term is used in CentOS and Redhat ). In Ubuntu and debian while enabling module only proxy and proxy_http term can be used.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Articles

  • Install n8n docker in Ubuntu for practicing
  • Bash Script: MySQL Database backup to AWS S3
  • Automate no touch Jenkins setup wizard on docker (jcac)
  • How to run and configure Jenkins in Docker container
  • Complete Guide: How to install Nagios Monitoring on AlmaLinux / Rocky Linux
  • Install KVM on Ubuntu 24.04 LTS ( Bash Script )
  • How to install GIMP 2.10 on Ubuntu / Debian
  • 5 ways to check Ubuntu version of system (commands and GUI)
  • How To Solve Forgot MySQL / MariaDB Root Password
  • Create Self Hosted Build Agent Docker Image for Azure DevOps

Copyright © 2026 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From India.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy