在宝塔面板上安装Godaddy SSL
把下载的Godaddy SSL文件中的两个crt合并为一个crt:
cat example.crt bundle.example.crt >> domain.crt
在Nginx的domain.conf中添加以下代码:
server {
listen 80 default_server;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
ssl_certificate /etc/nginx/certs/ssl_certificate.crt;
ssl_certificate_key /etc/nginx/certs/ssl_certificate.key;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;
ssl_certificate /etc/nginx/certs/ssl_certificate.crt;
ssl_certificate_key /etc/nginx/certs/ssl_certificate.key;
location / {
proxy_pass http://127.0.0.1:3000/;
}
}
在Laravel开启SSL
在App\ProvidersAppServiceProvider的boot方法中添加以下代码:
URL::forceScheme('https');
在laravel .env更改APP_URL的值=https://example.domain.com
APP_URL=https://example.domain.com