美文网首页
310-Nginx服务器支持https配置(七牛ssl证书)

310-Nginx服务器支持https配置(七牛ssl证书)

作者: 霄峰 | 来源:发表于2017-11-26 17:51 被阅读124次

Nginx服务器支持https配置(七牛ssl证书)


1. 第一步:去七牛官网申请ssl证书


2. 第二步:使用ssl证书来支持Nginx服务器https

前提:将下载的ssl证书上传到服务器的/var/cert/目录下(没有目录自行创建)

# SSL配置
server {
        listen 443;

        # 这里是你的www目录
        root /var/www/demo-video;

        # 这里添加index.php
        index index.php index.html index.htm;

        # 这里是你的域名
        server_name demo-video.yunfeng365.com;

        ssl on;
        ssl_certificate /var/cert/demo-video.yunfeng365.com.crt;
        # ssl_dhparam /var/cert/demo-video.yunfeng365.pem;
        ssl_certificate_key /var/cert/demo-video.yunfeng365.com.key;

        ssl_session_timeout 5m;

        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
        ssl_prefer_server_ciphers on;


        location / {
                # 支持index.php隐藏
                try_files $uri $uri/ /index.php?$query_string;
        }

        # 支持PHP
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass 127.0.0.1:9000;
        }
}

# 当访问`http://demo-video.yunfeng365.com`时,跳转到`https://demo-video.yunfeng365.com`
server {
        listen 80;

        # Make site accessible from http://localhost/
        server_name demo-video.yunfeng365.com;
        return 301 https://demo-video.yunfeng365.com$request_uri;
}


相关文章

网友评论

      本文标题:310-Nginx服务器支持https配置(七牛ssl证书)

      本文链接:https://www.haomeiwen.com/subject/titlbxtx.html