阿里云 Nginx SSL 证书配置

更新日期: 2019-05-10 阅读次数: 7000 字数: 132 分类: Nginx

申请免费的阿里云 SSL 证书

首先参考这里申请一个免费的阿里云 SSL 证书

七牛云 CDN SSL 证书过期处理

Nginx 配置

将 Nginx 对应的证书下载到服务器上,配置参考

server {
        listen       80;
        server_name  xxx.sunzhongwei.com;
        return       301 https://xxx.sunzhongwei.com$request_uri;
}

server {
        listen 443;
        server_name xxx.sunzhongwei.com;
        root /xxx/public;
        index index.html index.htm index.php;
        ssl on;
        ssl_certificate /xxx/storage/cert/xxx.sunzhongwei.com.pem;
        ssl_certificate_key /xxx/storage/cert/xxx.sunzhongwei.com.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        access_log /var/log/nginx/xxx-access.log access;
        error_log /var/log/nginx/xxx-error.log;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
}

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式