DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modern Digital Website Security: Prepare to face any form of malicious web activity and enable your sites to optimally serve your customers.

Containers Trend Report: Explore the current state of containers, containerization strategies, and modernizing architecture.

Low-Code Development: Learn the concepts of low code, features + use cases for professional devs, and the low-code implementation process.

E-Commerce Development Essentials: Considering starting or working on an e-commerce business? Learn how to create a backend that scales.

Related

  • How to Secure Your Website in 10 Easy Steps
  • Apache Ranger and AWS EMR Automated Installation and Integration Series (2): OpenLDAP + EMR-Native Ranger
  • Hardware-Accelerated OpenGL Rendering in a Linux Container
  • SSH Tutorial: Nice and Easy [Video]

Trending

  • AI in Java: Building a ChatGPT Clone With Spring Boot and LangChain
  • How To Get Cell Data From an Excel Spreadsheet Using APIs in Java
  • Navigating Software Leadership in a Dynamic Era
  • IoT Cloud Computing in IoT: Benefits and Challenges Explained

How to Configure Apache2 as Forward and Reverse Proxy

In this post, you will learn how to configure Apache 2 to act as a forward and reverse proxy by configuring forwarding and rewarding.

Sandra Parsick user avatar by
Sandra Parsick
·
Aug. 29, 17 · Tutorial
Like (3)
Save
Tweet
Share
22.0K Views

Join the DZone community and get the full member experience.

Join For Free

This is a cook recipe to configure an Apache2 as a forward and reverse proxy on Debian-based Linux systems like Ubuntu or Debian itself.

It is assumed that the apache2 package is already installed on your system. For the proxy feature, we have to install the Apache2 module libapache2-mod-proxy-html on the system and activate theses Apache modules. At the end, Apache2 has to be restarted, so that the modules can be used.

sudo apt-get install libapache2-mod-proxy-html
sudo a2enmod proxy
sudo a2enmod proxy_html
sudo a2enmod proxy_http
sudo service apache2 restart

Configuring Forwarding and Rewarding

We want to forward the URL request http://jenkins.mycompany.com to http://jenkins.mycompany.com:8083 and rewarding http://jenkins.mycompany.com:8083 to http://jenkins.mycompany.com for every response.

For that, we have to create a so-called Virtual Host in Apache2. It is easiest to copy the configuration of the default one and adjust it.

cd /etc/apache2/sites-available
sudo cp 000-default.conf jenkins_ci.conf

It is best practice to create one conf file per Virtual Host. Adding and removing Virtual Host is easier with this approach.

The content of the Virtual Host configuration should look similar to the following one:

<VirtualHost jenkins.mycompany.com:80>
ServerName jenkins.mycompany.com

ServerAdmin webmaster@localhost

ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8083/
ProxyPassReverse / http://localhost:8083/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

We have to add the host name (in this case jenkins.my.company.com) to the line 1 and 2, so that Apache2 knows for which host name is this Virtual Host. In line 11 and 12 the mapping is configured (in this case, everything that calls the host name directly should be forwarded to http://localhost:8083; the opposite for rewarding).

At the end, this configuration has to be enabled.

sudo a2ensite jenksin_ci.conf
sudo service apache2 reload

Further Information

  1. https://wiki.ubuntuusers.de/Apache/mod_proxy_html/
  2. https://wiki.ubuntuusers.de/Apache/Virtual_Hosts/
Host (Unix)

Published at DZone with permission of Sandra Parsick, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Secure Your Website in 10 Easy Steps
  • Apache Ranger and AWS EMR Automated Installation and Integration Series (2): OpenLDAP + EMR-Native Ranger
  • Hardware-Accelerated OpenGL Rendering in a Linux Container
  • SSH Tutorial: Nice and Easy [Video]

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: