标签:其他 ati dig ica secure cgi unit wiki []
HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。
更多基本介绍请查阅:
需要弄清楚的几个问题:
泛域名 SSL 证书 (Wildcard Domain SSL Certificates)
一个大概流程如下:
mkdir -p /etc/nginx/ssl/phphub
cd /etc/nginx/ssl/phphub
openssl genrsa -out phphub.orig 2048
运行
openssl req -new -key phphub.orig -out phphub.csr
输出, 需要填写内容:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.‘, the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:BeiJing
Locality Name (eg, city) []:BeiJing
Organization Name (eg, company) [Internet Widgits Pty Ltd]:The EST Group
Organizational Unit Name (eg, section) []:Dev
Common Name (e.g. server FQDN or YOUR name) []:*.phphub.org // ----------注意这个地方要认真填写
Email Address []: emailaddress @ gmail.com
Please enter the following ‘extra‘ attributes
to be sent with your certificate request
A challenge password []: ----------注意不填写----------
An optional company name []: ----------注意不填写----------
openssl rsa -in phphub.orig -out phphub.key
至此文件夹里面有 三个文件:
root@localhost:/etc/nginx/ssl/phphub# tree
.
├── ikbcity.csr
├── phphub.key
└── phphub.orig
购买细节这里省去, 需要注意的是要认准比较权威的认证机构购买...
购买成功后会给你发两个证书 server.crt 和 server.intermediate.crt, 生成最终的 server.chained.crt
cat server.crt server.intermediate.crt > phphub.crt
此文件就可以和上面生成的 key 文件一起用来配置 nginx 了:
ssl_certificate /etc/nginx/ssl/phphub/phphub.crt;
ssl_certificate_key /etc/nginx/ssl/phphub/phphub.key;
链接:
server {
listen 80;
listen 443 ssl;
server_name example.com;
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
....
}
X-Powered-By
header#fastcgi_hide_header X-Powered-By;
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
其他参照此 Gits: Nginx config on Gits
一般都会出现 cdn 服务器无法访问 https 源服务器的问题, 可以使用专门的域名 static.phphub.org
来解决, 此域名专门用来输送静态内容:
server {
listen 80;
server_name static.phphub.org;
root /var/www/phphub/public;
location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js) {
add_header Cache-Control public;
add_header Cache-Control must-revalidate;
expires 7d;
}
location / {
deny all;
}
}
可以利用 SSL Server Test -- 安全测试工具 去测试下你的 HTTPS 是否够安全.
标签:其他 ati dig ica secure cgi unit wiki []
原文地址:http://www.cnblogs.com/linkenpark/p/7283145.html