Category Archives: tomcat

How to set up HTTPS on Tomcat

Apache Tomcat, often referred to as Tomcat Server, is an open-source Java Servlet Container developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a “pure Java” HTTP web server environment in which Java code can run.

This Tomcat Tutorial will show you how to create a self signed cert that you can then use to secure Tomcat.

Step 1

Open a command prompt window and navigate to your JAVA_HOME bin folder, in our case:

C:\Program Files\Java\jre1.8.0_171\bin

Step 2

Enter the command:

keytool -genkey -alias tomcat -keyalg RSA -keystore “C:\apache-tomcat-8.5.34\conf\localhost.jks”

Note: You should update the tomcat path to match your path 

Step 3

You will then be prompted for a series of values, in our case we entered:

enter Keystore password: password
retype keystore password: password
what is your first and last name: localhost
what is the name of your orgainsation unit: IT
what is the name of your organisation: Darren
what is the name of your city: Dublin
what is the name of your state or province: Leinster
What is the two-letter country code for this unit: IE

When prompted type yes to confirm all is correct.

Next you will be asked to use the same password for <tomcat>, press enter here:

Step 4

Now open the tomcat server.xml file, in our case the file is located here:

C:\apache-tomcat-8.5.34\conf\server.xml

Step 5

Add the following block to the file:

	<Connector
		protocol="HTTP/1.1"
		port="8443" maxThreads="200"
		scheme="https" secure="true" SSLEnabled="true"
		keystoreFile="conf\localhost.jks" keystorePass="password"
		clinetAuth="false" sslProtocol="TLS" />

Step 6

Restart Tomcat.

Step 7

Navigate to https://localhost:8443.

You should first see a certificate warning, click to bypass the warning.

Step 8

You should now see Tomcat working over HTTPS

A full video tutorial can be found here:

How To Install Tomcat on CentOS 7

Hi there,

This short tutorial will show you how to install Tomcat 7 on CentOS 7.

“The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.”

The steps that you need to follow are detailed below. Just copy and paste them into your CentOS 7 server and all should work. If not please do comment below and I will respond as soon as I can.

First we need to download Tomcat:

  • sudo yum install tomcat

Now we will edit the tomcat.conf file, enter the below command to you CentOS machine:

  • sudo vi /usr/share/tomcat/conf/tomcat.conf

Now appened the below line to the end of the file.

JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx1026m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"

Next we’ll install the web application manager and the documentation, run the two following commands:

  • sudo yum install tomcat-webapps tomcat-admin-webapps
  • sudo yum install tomcat-docs-webapp tomcat-javadoc

Now we’ll edit the user.xml file to allow use to get into the web manger application, enter the following command:

  • sudo vi /usr/share/tomcat/conf/tomcat-users.xml

 

Next add this line between the <tomcat-users> Tags.

<user username="admin" password="password" roles="manager-gui,admin-gui"/>

Note the username and password, we will need this shortly.

Enter the two following commands to start the service and to ensure that the service is started when Centos powers on

  • sudo service tomcat start
  • sudo chkconfig tomcat on

Now, open a browser and navigate to localhost over port 8080

  • https://localhost:8080

you should see Tomcat running:

Now click Manager app

Enter the following details:

  • Username: admin
  • Password: password

You are now in the Web application manager.