nginx 搭建 https

先去申请一个免费的ssl证书,可以自己创建,也可以通过第三方来创建,我使用的是WOSIGN
然后将得到的两个文件 1_longquangege.cn_bundle.crt , 2_longquangege.cn.key 放到服务器上
接下来配置nginx的conf文件 下面是我个人的配置文件,参考使用
server {
listen 80;
listen 443 ssl;

server_name www.longquangege.cn longquangege.cn;
index index.html index.htm index.php;
root /var/www/CN_WordPress;

#ssl on;
ssl_certificate_key /usr/local/nginx/conf/vhost/ssl/2_longquangege.cn.key;
ssl_certificate /usr/local/nginx/conf/vhost/ssl/1_longquangege.cn_bundle.crt;

if ($server_port = 80) {
return 301 https://$server_name$request_uri;
}
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
error_page 497 https://$server_name$request_uri;

然后就是重启nginx服务 测试一下吧

  7 comments for “nginx 搭建 https

  1. 2016-08-16 at 19:20

    Now you tell me she’s not a knock-out!

  2. 2016-08-17 at 05:40

    Call it even.

  3. 2016-08-18 at 19:25

    Why do not we try this ?

  4. 2016-08-18 at 19:25

    I was wondering if after work we could grab a cup of coffee

  5. 2016-08-18 at 20:59

    this can be a very useful web site!

  6. 2016-08-19 at 00:28

    nice going!

  7. 2016-08-19 at 03:14

    You are so cute.

发表评论

邮箱地址不会被公开。