现在腾讯提供免费的一年证书,地址:https://console.qcloud.com/ssl
nginx重定向http自动跳转https
server
{
listen 80;
server_name www.moerats.com;
index index.html index.htm index.php;
rewrite ^/(.*)$ https://www.moerats.com/$1 permanent;
}
配置ssl证书
server
{
listen 443;
#listen [::]:80;
server_name www.moerats.com;
index index.html index.htm index.php;
root /app;
ssl on;
ssl_certificate /ssl/www.moerats.com.crt; #ssl.crt文件位置
ssl_certificate_key /ssl/www.moerats.com.key; #ssl.key文件位置
include typecho.conf;
#error_page 404 /404.html;
include enable-php-pathinfo.conf;
location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*/.(js|css)?$
{
expires 12h;
}
location ~ //.
{
deny all;
}
access_log off;
}
最后重启VPS
即可。
提示:军哥现在的lnmp1.4
可以直接添加ssl
证书了。
原创文章,作者:端木书台,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/246392.html