Wednesday, December 5, 2018

How to configure Mod_jk installation in AWS ec2 instance



The Apache Tomcat Connectors (Installation of Mod_jk Tomcat COnnectors)

Installation of Mod_jk First you need to install the Prerequest!!

Pre-request

yum install -y httpd24-devel gcc gcc-c++ make libtool

yum install libtool httpd24-devel autoconf.noarch

OR

go to your terminal and use the below command

wget  http://mirrors.estointernet.in/apache//httpd/httpd-2.4.38.tar.gz
tar -xzf httpd-2.4.38.tar.gz


Download the latest Apache from the Official Apache Website (https://httpd.apache.org/download.cgi)


Step:1



cd httpd-2.4.38

./configure --prefix=/usr/local/apache --enable-rewrite=shared --enable-proxy=shared
make
make install

Step:2

Install the JK connector (mod_jk) for tomcat Connectors

Now you can download tomcat connector (Mod_jk)


wget http://www.eu.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.46-src.tar.gz

Select the Latest which you Required.


Copy to this directory of /opt/

/opt/tomcat-connectors-1.2.46-src

Extract the Package which you donwload

tar -xvf tomcat-connectors-1.2.46-src.tar.gz

cd tomcat-connectors-1.2.46-src/

configure-make-make install the connector

./configure –with-apxs=/usr/bin/apxs

For UBUNTU ONLY THIS LINE(./configure --with-apxs=/usr/local/apache/bin/apxs)

make
libtool --finish /usr/lib64/httpd/modules
make install
service httpd restart

Step:3

Configuring the JK Connector Module


Create workers.properties file
Load and configure the JK connector module in apache httpd.conf file

GO to the Working directory path of /opt/tomcat-connectors-1.2.46-src/conf/
And open the worker.properties file (file path "/opt/tomcat-connectors-1.2.46-src/conf/workers.properties")

Put New entry in last paragh of

workers.tomcat_home=/opt/tomcat-connectors-1.2.46-src
workers.java_home=/usr/lib/jvm/jdk6
ps=/
worker.list=myworker
worker.myworker.port=8009
worker.myworker.host=localhost
worker.myworker.type=ajp13
worker.myworker.lbfactor=1



Step :4

Create the file of mod_jk.conf in the directory of "/etc/httpd/conf.d/mod_jk.conf" and put the entry .


LoadModule jk_module modules/mod_jk.so
JkWorkersFile /opt/tomcat-connectors-1.2.46-src/conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"



Test the configuration are configured successfully  .

httpd -t


Step:5

Apply the Virtual Host Concept

Open the path of /etc/httpd/conf.d/domain.example.com.conf

<VirtualHost *:80>
    ServerName domain.example.com
    DocumentRoot /var/www/vhosts/domain.example.com/public_html

    CustomLog /var/www/vhosts/domain.example.com/statistics/logs/access_log combined
    ErrorLog  /var/www/vhosts/domain.eample.com/statistics/logs/error_log

   <Directory /var/www/vhosts/domain.example.com/public_html>
    Options -Includes +FollowSymLinks +MultiViews
   AllowOverride All
   Order allow,deny
   Allow from al
  </Directory>
   JkMount /* myworker
 </VirtualHost>

          Restart the Tomcat and apache Httpd service


                  Thats it you done the Mod_jk Installation !!!.











Friday, July 6, 2018

Configure EC2 Instance Apache Web Server on Amazon Linux 2 to Use SSL/TLS

step: 1

[ec2-user~] sudo yum update -y

Now that Your Instance is current , add SSL/TLS suppport by installing the Apache Module mod_ssl


Pre-Request

Configure your security group to allow your instance to accept connections on the following TCP ports:

SSH (port 22)
HTTP (port 80)
HTTPS (port 443


CentOS-7.X 

[ec2-user ~]$ sudo systemctl is-enabled httpd
sudo systemctl start httpd && sudo systemctl enable httpd

CentOS-6.X

Step 2

sudo yum install mod24_ssl

It have been installed mod_ssl TO configure an Modssl

The configuration file for mod_ssl. It contains "directives" telling Apache where to find encryption keys and certificates


Copy your existing SSL certificate to below mentioned path .

/etc/pki/tls/certs/example_domainname_com-ca.crt
/etc/pki/tls/private/example_domainname_com.key
/etc/pki/tls/certs/example_domainname_com.crt

/etc/httpd/conf.d/example.domainname.com.conf
________________________________________________________________________________
### trial.example.com - GENERATED AUTOMATICALLY ###
<VirtualHost *:80>
    ServerName trial.example.com
    ServerAlias www.trial.example.com
    DocumentRoot /var/www/vhosts/trial.example.com/webapp/public_html
    #Redirect permanent / https://trial.example.com/
    #RedirectMatch ^((?!\/(\/jsp\/viewReportData.jsp)).*)$ https://%{HTTP_HOST}$1

RewriteEngine On

# Go to https if not on /your-page-url/

RewriteCond %{SERVER_PORT} =80
RewriteCond %{THE_REQUEST} !/jsp/viewReportData.jsp [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


    CustomLog /var/www/vhosts/trial.example.com/statistics/logs/access_log combined
    ErrorLog  /var/www/vhosts/trial.example.com/statistics/logs/error_log

    <Directory /var/www/vhosts/trial.example.com/webapp/public_html>
        Options -Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
       JkMount /* myworker
</VirtualHost>

<VirtualHost *:443>
    ServerName trial.example.com
    ServerAlias www.trial.example.com
    DocumentRoot /var/www/vhosts/trial.example.com/webapp/public_html

RewriteEngine On

# Go to http if on /your-page-url/

RewriteCond %{SERVER_PORT} !=80
RewriteCond %{THE_REQUEST} /jsp/viewReportData.jsp [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    SSLEngine ON
    SSLCACertificateFile /etc/pki/tls/certs/trial.example.com-ca.crt
    SSLCertificateKeyFile /etc/pki/tls/private/trial.example.com.key
    SSLCertificateFile /etc/pki/tls/certs/trial.example.com.crt

    CustomLog /var/www/vhosts/trial.example.com/statistics/logs/access_ssl_log combined
    ErrorLog  /var/www/vhosts/trial.example.com/statistics/logs/error_ssl_log

    <Directory /var/www/vhosts/trial.example.com/webapp/public_html>
        Options -Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
     JkMount /* myworker
</VirtualHost>

___________________________________________________________________________________
Once the configuration file completed

Step:3

execute the below command to reflect

httpd -t

/etc/init.d/httpd restart

That it enjoy the SSL installation experience !!!