要配置ssl证书,首先要买一下ssl证书,能够在多个平台上购买,阿里云,腾讯云等,还有一些专门卖ssl证书的网站,今天在这里给你们介绍的是一个免费证书的网站。php
FreeSSL.org 是一个提供免费HTTPS证书申请的网站,而后在首页的输入框内输入你的网站的一级域名而后回车,如今默认是 亚洲诚信的ssl证书无偿使用1年,而后输入邮箱,以后须要域名作一下TXT解析(这个是为了校验一下你是否是域名拥有者)css
server {
listen 80;
server_name baidu.com www.baidu.com;
index index.html index.htm index.php;
root /alidata/www/wewe/public;
location / {
index index.php index.html index.htm;
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php last;
}
#引用PHP CGI
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
复制代码
listen 443 ssl;#这个443端口和80端口能够同时监听,同时监听就是http和https均可用,只监听443就是强制https
server_name wewe.weinvestment.cn;
index index.html index.htm index.php;
root /alidata/www/wewe/public;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate /alidata/server/cert2/full_chain.pem;#这个地方就是刚才证书上传的路径
ssl_certificate_key /alidata/server/cert2/private.key;#这个地方就是刚才证书上传的路径
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
复制代码
server {
listen 80;
listen 443 ssl;
server_name baidu.com www.baidu.com;
index index.html index.htm index.php;
root /alidata/www/wewe/public;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate /alidata/server/cert2/full_chain.pem;
ssl_certificate_key /alidata/server/cert2/private.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
location / {
index index.php index.html index.htm;
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php last;
}
#引用PHP CGI
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
复制代码
nginx -t
html
service nginx restart
nginx