码迷,mamicode.com
首页 > Web开发 > 详细

Nginx配置站点https

时间:2018-05-08 22:31:55      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:申请   php   try   null   source   cal   ima   aes   ram   

step 1: 检查nginx的编译参数

使用nginx -V可以查看,如果编译参数中包含http_ssl_module,可以继续下一步操作,如果没有,则需要从新编译。

技术分享图片

step 2: 申请证书

目前,阿里云等云平台可以申请一定时间的免费证书,这里大家可以自行找下,不再多说

step 3: 配置nginx.conf

server {
    listen 443;
    server_name hae.top;
    ssl on;
    ssl_certificate      /usr/local/nginx/key/214665654330627.pem;
    ssl_certificate_key  /usr/local/nginx/key/214665654330627.key;
    ssl_session_timeout  5m;
    ssl_protocols  TLSv1 TLSv1.1  TLSv1.2;
    ssl_ciphers     ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_prefer_server_ciphers   on;


    index index.html index.htm index.php;
    root  /home/wwwroot/default/public;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ [^/]\.php(/|$) {
        # comment try_files $uri =404; to enable pathinfo
        try_files $uri =404;
        fastcgi_pass unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
        fastcgi_param PHP_ADMIN_VALUE "open_basedir = /home/wwwroot: /temp/:/proc";
    }
}

接着使用https访问站点即可

Nginx配置站点https

标签:申请   php   try   null   source   cal   ima   aes   ram   

原文地址:https://www.cnblogs.com/feanmy/p/nginx-https.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!