什么是HTTPS?
HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容 就需要SSL。 它是一个URI scheme(抽象标识符体系),句法类同http:体系。用于安全的HTTP数据传输。https:URL表明它使用了HTTP,但HTTPS存在不同 于HTTP的默认端口及一个加密/身份验证层(在HTTP与TCP之间)。这个系统的最初研发由网景公司进行,提供了身份验证与加密通讯方法,现在它被广 泛用于万维网上安全敏感的通讯,例如交易支付方面。
操作环境 一.Nginx + https + 免费SSL证书配置指南生成证书
编辑 nginx.conf
OK, 完成了。但这样证书是不被信任的,要被信任还需要购买相关证书(http://www.godaddy.com/ssl/ssl-certificates.aspx?ci=8979) 验证配置: https://127.0.0.1 二.Tomcat SSL配置
1. 生成 server key :
keypass 和 storepass 两个参数后面跟的是密码。
配置TOMCAT
修改%TOMCAT_HOME%confserver.xml,以文字编辑器打开,查找这一行:
将之后的那段的注释去掉,并加上 keystorePass及keystoreFile属性。
注意,tomcat不同版本配置是不同的:
Tomcat4.1.34配置:
xml 代码
Tomcat5.5.9配置:
Tomcat5.5.20配置(此配置同样可用于Tomcat6.0):
Tomcat6.0.10配置:
tomcat6支持3种,请参考以下文档: http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html 验证配置 :访问 https://127.0.1.1:8443/ 三。综合配置 前段静态内容处理:nginx 配置
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
gzip on;
gzip_static on;
gzip_comp_level 5;
gzip_min_length 1024;
keepalive_timeout 65;
limit_zone myzone $binary_remote_addr 10m;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name localhost;
location ~ .(htm|html|gif|jpg|jpeg|png|ico|rar|css|js|zip|txt|flv|swf|doc|ppt|xls|pdf)$ {
index index.jsp index.html;
root /home/tomcat/webapps;
access_log off;
expires 24h;
}#nginx处理静态内容 location /{
proxy_pass http://127.0.0.1:8080; #提交给后端的tomcat处理 }
}
验证配置: https://127.0.0.1 (责任编辑:IT) |

