配置本地网站HTTPS

1. 使用openssl生成密钥privkey.key:

openssl genrsa -out privkey.key1024

2. 使用密钥生成证书server.pem:

openssl req -new -x509 -key privkey.key -out server.pem -days 365

只填写Common Name(域名)

例 Common Name (e.g. server FQDN or YOUR name) []: xxx.com

也可以*.xxx.com配二级域名

3,配置Nginx

server {

     listen 80; 

     server_name xxx.com; 

    **

     listen 443 ssl; 

     ssl on; 

     ssl_certificate F:/server.pem; 

     ssl_certificate_key F:/privkey.key;

    # 强制HTTPS

     if ($scheme = http) { return 301 https://$server_name$request_uri; }

你可能感兴趣的:(配置本地网站HTTPS)