Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Set up Apache as a Proxy to Tomcat

Welcome to this hands-on lab for setting up an Apache web server as a proxy front end to Tomcat, a Java-based application platform built around deploying and managing Java Web Applications. The provided server is running Red Hat Enterprise 8. Tomcat 9 is pre-installed and available for you on port **8080** at the server's public IP address. You will be tasked with making Tomcat available on port **80** via the Apache httpd server. Once you have completed the task you will need to test, to ensure you can connect via port **80** and access the Tomcat GUI.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon May 08, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Test to Ensure You Can Access the Preconfigured Tomcat Instance by Using the Server's Public IP Address and Port 8080

    It may take from 3 to 10 minutes after the hands-on lab has started before you can access the Tomcat server on port 8080.

    To access the server, copy the external IP address (from the hands-on lab overview page) and test in your browser by using this IP address and appending :8080 to it.

    For example, if the IP address shown was 3.92.152.3 then you would put the following URL into your web browser:

    http://3.92.152.3:8080

    You should be able to see the GUI.

  2. Challenge

    Install the Apache Web Server onto the Provided Lab Server

    Log into the server's console and install the Apache web server:

    sudo dnf install httpd
    
    sudo systemctl enable httpd
    
    sudo systemctl start httpd
    
    

    Go to a browser and test that the Apache web server is working. You should see the default Apache web page.

  3. Challenge

    Configure the Apache Web Server, via Virtual Host Setup, as a Proxy to the Tomcat Instance

    Create a virtual host entry inside an Apache configuration file. This file should be called tomcat_manager.conf:

    sudo vim /etc/httpd/conf.d/tomcat_manager.conf
    

    You can use the following as an example of what needs to be inside this configuration file:

    <VirtualHost *:80>
        ServerAdmin root@localhost
        ServerName myserversystem.mylabserver.com
        DefaultType text/html
        ProxyRequests on
        ProxyPreserveHost On
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/
    </VirtualHost>
    
  4. Challenge

    Either Disable or Change SELinux so That the Proxy Will Work

    SELinux is enabled on the hands-on lab server. You can choose to disable it or adjust it so it will allow the Apache web server to act as a proxy.

    To disable SELinux you would do the following:

    sudo setenforce permissive 
    

    Then edit the SELinux configuration file to make the server permissive:

    sudo vim /etc/selinux/config 
    

    Once in the editor, change this line:

    SELINUX=enforcing
    

    Make it permissive, instead of enforcing:

    SELINUX=permissive
    

    Then save the file.

    If you wish to keep SELinux enabled and allow it to permit the Apache web server to work as a proxy, you would run the following commands:

    sudo setsebool -P httpd_can_network_connect 1
    
    sudo setsebool -P httpd_can_network_relay 1
    
    sudo setsebool -P httpd_graceful_shutdown 1
    
    sudo setsebool -P nis_enabled 1  
    
  5. Challenge

    Restart the Apache Web Server and Look for Errors

    Restart the Apache web server and check for errors:

    systemctl restart httpd
    

    If there are errors and Apache does not start, then troubleshoot those errors.

  6. Challenge

    Test You Can Access Tomcat via Port 80

    You should be able to see the Tomcat GUI being served out on port 80.

    If this does not work, or there is an error, troubleshoot the installation.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans