April 23
Nginx中的https加速网站响应解决方案
https不仅仅安全,2017下半年开始各大搜索引擎会优先收录https站点,https消耗最大的是握手过程,所以要比http慢很多,很多站长不太愿意启用。下面按照我列出的方法,写入到你的配置当中,可以明显为给你的https加速,效果立竿见影!
加速配置
#HTTP_TO_HTTPS_END
ssl_certificate /etc/letsencrypt/live/你的域名/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/你的域名/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_stapling on;
resolver 8.8.8.8 114.114.114.114 valid=3600s;
ssl_prefer_server_ciphers on;
ssl_stapling_verify on;
ssl_dhparam dh2048.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
error_page 497 https://$host$request_uri;
使用方法
打开网站-对应网站设置-配置文件,然后从你的ssl证书后面一行开始替换,其中dh2048.pem文件需要手动生成:
cd /www/ && openssl gendh -out dh2048.pem 2048 && cp -i /www/dh2048.pem /www/server/nginx/conf/
直接在宝塔-文件的shell命令中输入或ssh连接后执行,文件会自动生成完毕,之后重启nginx即可,效果立竿见影。
来源:https://tghello.com/170.html
:D 少女祈祷中...