阿里云Centos服务器Nginx配置https

准备工作

  1. Centos服务器(阿里云官网购买
  2. 服务器上安装Nginx成功安装(Nginx部署安装
  3. 阿里云上已经申请并颁发证书。(阿里云控制台->安全(云盾)->CA证书服务->申请)

证书安装

  1. 下载已签发证书
  2. 登录服务器,在Nginx的安装目录下创建cert目录,并且将下载的全部文件拷贝到cert目录中。
  3. 打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件,找到:
    # HTTPS server
    # #server {
    # listen 443;
    # server_name localhost;
    # ssl on;
    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.key;
    # ssl_session_timeout 5m;
    # ssl_protocols SSLv2 SSLv3 TLSv1;
    # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    # ssl_prefer_server_ciphers on;
    # location / {
    #
    #
    #}
    #}
    
  4. 将其修改为 (以下属性中ssl开头的属性与证书配置有直接关系,其它属性请结合自己的实际情况复制或调整) :
    server {
        listen 443;
        server_name localhost;
        ssl on;
        root html;
       index index.html index.htm;
      ssl_certificate   cert/214509357020752.pem;
       ssl_certificate_key  cert/214509357020752.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;
        ssl_prefer_server_ciphers on;
       location / {
           root html;
           index index.html index.htm;
       }
    }
    
  5. 保存文件并重启Nginx: nginx -s reload
feihu分享到:

          

You may also like...

Scroll Up