首先申請(qǐng)一份SSL證書,獲得證書文件.crt
矛缨,證書key文件.key
。
Nginx配置如下
server {
listen 80;
server_name website.com;
# 重定向至https
rewrite ^(.*)$ https://$host$1 permanent;
}
server{
listen 443 ssl;
server_name walterbright.cc;
# ssl 證書路徑
ssl_certificate path/cert.crt;
# ssl key 路徑
ssl_certificate_key path/cert.key;
location / {
root /site/;
}
}