Tomcat and httpd configured in port 8080 and 80

By: Emiley J Emailed: 1728 times Printed: 2328 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

When you install Tomcat in your server, by default it uses port 8080. Typically in a linux system, you can install apache2 or httpd as a web server that handles the default port 80 and then uses mod_proxy to send requests to Tomcat at port 8080 for sites hosted in Tomcat.

httpd (or apache2) are great for hosting multiple websites (multiple domains) in a single server. In this example, we will install, httpd in port 80 and Tomcat7 in port 8080 and then configure both of them to handle requests seamlessly.

Install and configure httpd

  • yum install httpdYou could ofcourse use apt-get instead of yum depending on your platform
  • vim /etc/httpd/conf/httpd.conf
    Look for the following modules and enable them if they are not already enabled
    LoadModule proxy_module modules/
    LoadModule proxy_http_module modules/

    Then uncomment, the following line
    NameVirtualHost *:80

    Uncomment the following lines at the bottom and change it to point to your default domain.

    <VirtualHost *:80>
        DocumentRoot /var/www/html
        ErrorLog logs/default-error_log
        CustomLog logs/default-access_log common

    Save and close the file by pressing 'Esc' and the typing :wq! and Enter.
  • service httpd start

Intall and configure tomcat7

  • yum install tomcat7-webapps tomcat7-docs-webapp tomcat7-admin-webapps
  • under /etc/httpd/conf.d create a file named mytomcatapp.conf and copy the below code
  • <VirtualHost *:80>
    ProxyPass         /  http://localhost:8080/
    ProxyPassReverse  /  http://localhost:8080/
    ProxyRequests     Off
    # Local reverse proxy authorization override
    # Most unix distribution deny proxy by default 
    # (ie /etc/apache2/mods-enabled/proxy.conf in Ubuntu)
    <Proxy http://localhost:8080/*>
      Order deny,allow
      Allow from all

You have now installed both httpd and tomcat7 and configured them. You now have to start/restart both services

service httpd restart
service tomcat7 restart

Now when you goto your in your browser, the request is direclty handled by httpd service and the index file from your /var/www/html folder will be returned to the browser.

If you goto in your browser, the request will be forwarded by httpd service to the tomcat7 internally and your tomcat application will serve the pages.

The domains and are used for illustration purposes only. You have to use your own valid domains, and the DNS A records have to be created to point to the IP address of your server

Java Home | All Java Tutorials | Latest Java Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Bookmark and Share


Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by Emiley J
Password must include both numeric and alphabetic characters - Magento
What is Hadoop?
Returning multiple values from a web service
Tomcat and httpd configured in port 8080 and 80
Java Webservices using Netbeans and Tomcat
Java WebService connected to Database
How to Deploy a Java Web Service
Call a webservice in Java
Java WebService - Create your first web service in Java
package javax.jws does not exist
Getting Started with Android
HTML5 Location - getCurrentPosition() in HTML5
HTML5 Canvas - Using Canvas in HTML5
HTML5 - Introduction
HTML5 Video - Handling video in HTML5

More Tutorials in Java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Java File
Java String
Count number of vowels, consonants and digits in a String in Java
Reverse a number in Java
Student marks calculation program in Java
Handling Fractions in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Multiple Inheritance sample in Java
Java program using Method Overriding
Java program to check if user input is an even number

More Latest News
Most Viewed Articles (in Java )
How to Send SMS using Java Program (full code sample included)
XML and Java - Parsing XML using Java Tutorial
The Basic Structure of a Simple Java program
Method Overriding in Java
Recursion in java
Method Overloading (function overloading) in Java
wait(), notify() and notifyAll() in Java - A tutorial
How to use ArrayList in Java
FileReader and FileWriter example program in Java
Using StringTokenizer in Java
Vector example in Java
Stack example in Java - push(), pop(), empty(), search()
Using One-Dimensional Arrays in Java
Transient vs Volatile modifiers in Java
Count number of vowels, consonants and digits in a String in Java
Most Emailed Articles (in Java)
FileOutputStream - sample program in Java
Palindrome String in Java
SequenceInputStream example program in Java
Student marks calculation program in Java
Multiple Inheritance sample in Java
Java program to check if user input is an even number
Draw a bar chart in Java
Write to a file in Java - Sample Program
cloneable in Java
How to modify the objects using java classes
Java program for changeable wrapper class
How to reverse the elements in a Single dimension array and display the output
How to count the number of digits in any Input number other than negative numbers
Creating Users and Passwords with Tomcat using tomcat-users.xml
Using Parameters in JasperReports