https://console.cloud.tencent.com/ssl
会有黄字提醒下面这个,不用管
您有1个SSL证书未完成身份验证,请尽快处理
一步一步走,申请成功之后,等一段时间(我的没超过一小时)。可以下载
下载下来的文件有下面几个,服务器配置用的是哪个就选择哪个使用
选择nginx里的两个文件:
.cn_bundle.crt
.cn.key
在服务器的项目代码目录,创建crt文件夹,把两个文件上传到crt文件夹中,我用的是laravel项目,所以实在这个目录下
在nginx配置下修改,你的可能是别的路径
sudo vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name 域名;
set $root_path ‘public地址‘;
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 443 ssl http2;
server_name 域名 ;
root public地址;
index index.php index.html index.htm;
ssl off; # 开启ssl证书访问
ssl_certificate .cn_bundle.crt路径;
ssl_certificate_key .cn.key路径;
ssl_session_timeout 10m; # session有效期10分钟
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # 协议版本 按照这个协议配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
ssl_prefer_server_ciphers on;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php$query_string;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
nginx重启
sudo systemctl restart nginx
如果报如下错误
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
查看错误信息
systemctl status nginx.service
如果报下面的错,证书路径错误修改路径
nginx.service - The nginx HTTP and reverse proxy server
重启出现下边成功
Redirecting to /bin/systemctl restart nginx.service
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。