步驟以下:apache
(1)cd /etc/apache2/mods-availalbetomcat
cp rewrite.load ssl.conf ssl.load /etc/apache2/mods-enabled (加載rewrite.load ssl.conf ssl.load)測試
(2)vi /etc/apache2/sites-available/default-ssl.conf (配置apache,添加以下代碼:)ui
SSLProxyEngine Onrest
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RequestHeader set Front-End-Https "On"
ProxyVia On
ProxyPreserveHost On
ProxyRequests Offssl
ProxyPass / https://127.0.0.1:8443/
ProxyPassReverse / https://127.0.0.1:8443/it
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
Require all granted
</Location>io
RewriteEngine Ontest
Options +FollowSymLinks配置
RewriteCond %{SERVER_PORT} !^8443$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}$1 [L,R=301]
(3)保存退出:wq
(4)sudo apache2ctl configtest (測試,若是現實OK,正面成功,若是出錯,多是關聯文件沒有加載到mods-enabled,按照步驟(1)加載相應的文件)
(5)sudo /etc/init.d/apache2 restart (重啓apache)
(6)輸入:https://localhost:443 (若是看到tomcat首頁,而且是https,說明配置成功)