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
原文地址:https://www.cnblogs.com/feanmy/p/nginx-https.html