云服务器(uCloud)部署java web项目(七) apacheHTTPS转发到tomctHTTPS
步骤如下:
(1)cd /etc/apache2/mods-availalbe
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,添加如下代码:)
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RequestHeader set Front-End-Https "On"
ProxyVia On
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / https://127.0.0.1:8443/
ProxyPassReverse / https://127.0.0.1:8443/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
Require all granted
</Location>
RewriteEngine On
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,说明配置成功)