在Nginx服务器下配置StartSSL和SSL的教程

2019-10-17 20:10:51王振洲

然后编辑 e2fsck.org.crt  把里面的

—–END CERTIFICATE———-BEGIN CERTIFICATE—–

分开,改成这样

—–END CERTIFICATE—–
—–BEGIN CERTIFICATE—–

 

第三步 配置 nginx.conf

主要是修改这段

server {   listen    443;   server_name www.e2fsck.org;   index index.html index.htm index.php;   ssl         on;            <span id="note">#主要是这段</span>   ssl_certificate   e2fsck.org.crt;   ssl_certificate_key e2fsck.org_nopass.key;   ssl_session_timeout 5m;   ssl_protocols SSLv2 SSLv3 TLSv1;   ssl_ciphers HIGH:!aNULL:!MD5;   ssl_prefer_server_ciphers  on;   location ~ .php$ {               <span id="note">#这一小段是为了 https 能解析 php</span>     root      html;     fastcgi_pass  127.0.0.1:9000;     fastcgi_index index.php;     fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;     fastcgi_param HTTPS on;     include    fastcgi.conf;   }   if (-f $request_filename/index.html){      <span id="note">#如果非SSL做了伪静态,这里也要</span>     rewrite (.*) $1/index.html break;   }   if (-f $request_filename/index.php){      rewrite (.*) $1/index.php;   }   if (!-f $request_filename){     rewrite (.*) /index.php;   }   #location / {   #root  html;   #index index.html index.htm index.php;   #} }

然后重启 nginx (如果以前没配置过 ssl,就一定要重启, reload 没用)

 

第四步 测试 ssl

浏览器输入 https://www.e2fsck.org 可以看到 ssl 已经可以正常工作了