Nignx支持ssl证书

2019-03-04 Nginx 1933

nignx需要配置ssl模块

编译nginx时指定 –with-http_ssl_module 参数

环境需要安装openssl和openssl-devel

方法自行搜索

申请证书

申请免费SSL证书

上传证书

  • 申请的证书包含: ca_bundle.crt certificate.crt private.key

  • ca_bundle.crt certificate.crt 两个证书用sublime打开,合并到一个文件,起名 abc_com.pem

  • 重命名 abc_com.key

  • 上传到 nginx/conf/cert 目录

修改nginx配置文件

# http和https可同时访问
server {
	 listen 80;
	 listen 443 default ssl;
	 server_name localhost;
	 ssl on;
	 root html;
	 index index.html index.htm;
	 ssl_certificate   cert/abc_com.pem;
	 ssl_certificate_key  cert/abc_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;
	 ssl_prefer_server_ciphers on;
	 location / {
		 root html;
		 index index.html index.htm;
	 }
}

更多可参考:nginx支持ssl访问

0