====== Tomcat ======
==== Tomcat SSL ====
==== Setting up tomcat with HTTP Native library. ===
==== Setting up HSTS with HTTP Native Library. ====
httpHeaderSecurity
org.apache.catalina.filters.HttpHeaderSecurityFilter
hstsMaxAgeSeconds
31536000
antiClickJackingEnabled
false
hstsIncludeSubDomains
true
true
httpHeaderSecurity
/*
==== Setting up redirect ====
Entire Application
/*
CONFIDENTIAL
==== RHEL 8 / Tomcat 9====
=== Install Packages ===
dnf install java-1.8.0-openjdk-devel tar apr-util-devel apr-util-openssl gcc openssl-devel
=== Create User ===
groupadd --system tomcat -g 91 # with group id 91
useradd -u 91 -d /usr/share/tomcat -r -s /bin/false -g tomcat tomcat # with user id 91
=== Download Tomcat Package ===
export TOM_VERSION="9.0.36"
wget "https://apache.osuosl.org/tomcat/tomcat-9/v${TOM_VERSION}/bin/apache-tomcat-${TOM_VERSION}.tar.gz"
=== Extract Package ===
tar -xvf apache-tomcat-${TOM_VERSION}.tar.gz -C /usr/share/
ln -s /usr/share/apache-tomcat-${TOM_VERSION} /usr/share/tomcat
=== Set Ownership ===
chown -R tomcat:tomcat /usr/share/tomcat
chown -R tomcat:tomcat /usr/share/apache-tomcat-${TOM_VERSION}
=== Systemd service ===
[Unit]
Description=Tomcat Server
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment='JAVA_OPTS=-Djava.awt.headless=true'
Environment=CATALINA_HOME=/usr/share/tomcat
Environment=CATALINA_BASE=/usr/share/tomcat
Environment=CATALINA_PID=/usr/share/tomcat/temp/tomcat.pid
Environment='CATALINA_OPTS=-Xms512M -Xmx3072M'
ExecStart=/usr/share/tomcat/bin/catalina.sh start
ExecStop=/usr/share/tomcat/bin/catalina.sh stop
[Install]
WantedBy=multi-user.target
=== Backup / Remove examples ===
cp -Rp /usr/share/tomcat/webapps /usr/share/tomcat/webapps.bk
rm -rf /usr/share/tomcat/webapps/{docs,examples,ROOT}
=== Set User ===
=== Tomcat Native ===
cd /usr/share/tomcat/bin
tar -xvf tomcat-native.tar.gz
cd tomcat-native-1.2.24-src/native
./configure --with-java-home=/usr/lib/jvm/java-openjdk --with-ssl=yes --prefix=/usr/share/tomcat
make && make install
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
export LD_LIBRARY_PATH
:!: Set SSL[[tomcat#tomcat_ssl|tomcat#tomcat_ssl]] \\
:?: Set Auto redirect if needed [[tomcat#setting_up_redirect|tomcat#setting_up_redirect]]
=== Start Service ===
systemctl daemon-reload
systemctl enable tomcat
systemctl start tomcat
=== Firewall ===
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=8443/tcp
firewall-cmd --reload