在nginx中给域名配置SSL证书,即实现https访问

原理:反向代理

在nginx.conf配置文件中增加如下代码即可

配置完成后需重启nginx

server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  xxxxx.com;    //访问的域名
        ssl_certificate "/usr/local/nginx/cert/26cd05dds__ieou.com.pem";   //证书路径
        ssl_certificate_key "/usr/local/nginx/cert/26d35dds__ieou.com.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_prefer_server_ciphers on;
        location / {
            proxy_pass   http://localhost:8007;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
        }
} 
posted @ 2021-04-28 14:47  低调的小白  阅读(1114)  评论(0编辑  收藏  举报