CentOS7下Apache及Tomcat开启SSL

参考:

  •   http://www.bootf.com/563.html
  •   http://www.sunjianhe.com/?p=1238
  •   http://www.fwolf.com/blog/post/405
  •   http://httpd.apache.org/docs/2.4/ssl/ssl_howto.html

 

安装:

yum install -y openssl    #使用openssl可手动创建证书
yum install -y httpd
yum install -y mod_ssl
#防火墙打开80、443端口,然后重启 firewall
-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload
#Apache开启
systemctl enable httpd systemctl start httpd

强制HTTP-->HTTPS:

#vim /etc/httpd/conf/httpd.conf 添加如下内容
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$      #另一种写法:RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]   #301表示永久移走

 【Tomcat开启SSL】

http://sanketdangi.com/post/43734145363/secure-tomcat-through-apache-using-ajp

#vi /etc/httpd/conf.d/ssl.conf 添加如下内容 application1,application2代表tomcat应用,请替换
ProxyPass /application1 ajp://127.0.0.1/application1
ProxyPass /application2 ajp://127.0.0.1/application2
ProxyPassReverse /application1 ajp://127.0.0.1/application1
ProxyPassReverse /application2 ajp://127.0.0.1/application2

<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
#vim /usr/share/tomcat/conf/server.xml
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
                 ||
                            \ /
<Connector port="8009" protocol="AJP/1.3" redirectPort="8080" />

[work]

http://blog.csdn.net/lifetragedy/article/details/7699236

[解决[Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed]

  原因:requests模块验证证书,自签名证书验证失败。

http://stackoverflow.com/questions/10667960/python-requests-throwing-up-sslerror

http://stackoverflow.com/questions/18999517/python-requests-certificate-verify-failed

http://www.python-requests.org/en/latest/user/advanced/

https://www.digicert.com/ssl-support/pem-ssl-creation.htm

http://viraj-workstuff.blogspot.jp/2011/07/python-httplib2-certificate-verify.html

方案一:

requests.get(url,verify=False)

方案二:

复制pem文件内容至/usr/lib/python2.7/site-packages/requests/cacert.pem

posted @ 2015-03-04 15:18  flowjacky  阅读(3814)  评论(0编辑  收藏  举报