首先说明tomcat的默认端口(http端口)是8080,ajp端口是8009,https端口是443

         ubuntu使用apt-get install apache2 tomcat7 安装后,打开apache配置文件000-default在文件末尾添加如下配置:

     1.转发到http端口:

          ProxyPreserveHost On       

          ProxyPass / http://127.0.0.1:8080/
          ProxyPassReverse / http://127.0.0.1:8080/

      2.转发到ajp端口:

          ProxyPreserveHost On

          ProxyPass / ajp://127.0.0.1:8009/
          ProxyPassReverse / ajp://127.0.0.1:8009/

      1. 转发到http端口需要加载proxy.conf  proxy_connect.load proxy.load  proxy_http.load 到/etc/apache2/mods-enabled/下。

      2. 转发到http端口需要加载proxy.conf  proxy_connect.load proxy.load proxy_ajp.load到/etc/apache2/mods-enabled/下。

       3.从启apache

     在此基础上加上安全机制实现http与https的转换

          1.加载rewrite.load ssl.conf  ssl.load到/etc/apache2/mods-enabled/下。

          2. 加载000-default-ssl到/etc/apache2/sites-enables/下

          3.修改000-default-ssl文件

              1.添加ca证书

                 SSLCertificateFile /etc/apache2/conf/*****/ssl.crt
                 SSLCertificateKeyFile /etc/apache2/conf/******/ssl.key
                 SSLCertificateChainFile /etc/apache2/conf/****/sub.class1.server.ca.pem
                 SSLCACertificateFile /etc/apache2/conf/****/ca.pem                 
               2.添加转发 

                  ProxyPreserveHost On

                  ProxyPass / ajp://127.0.0.1:8009/
                  ProxyPassReverse / ajp://127.0.0.1:8009/

               3.添加转发机制

                   RewriteEngine On
                   RewriteCond %{SERVER_PORT} !^80$
                   RewriteCond %{HTTP_HOST}  www.*****.com
                   RewriteCond %{REQUEST_URI}  ^/***/add.jsf
                   RewriteRule ^(.*)  http://%{HTTP_HOST}%{REQUEST_URI} [L,R= 301 ]

            4.修改000-default文件

                 1.添加转发机制

                    RewriteEngine On
                    RewriteCond %{SERVER_PORT} !^443$
                    RewriteCond %{HTTP_HOST}  www.*****.com
                    RewriteCond %{REQUEST_URI}  ^/*****/profile/*
                    RewriteRule ^(.*)  https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

             5.重启apache