CentOS7下Apache及Tomcat开启SSL

安装:

复制代码
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

AddDefaultCharset off
Order deny,allow
Allow from all

复制代码

vim /usr/share/tomcat/conf/server.xml

                 ||
\ /

[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://*.com/questions/10667960/python-requests-throwing-up-sslerror

http://*.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

上一篇:C#委托详解(2):实现方式大全


下一篇:jquery 1.9里面已经删除了toggle(fn1, fn2)函数: