请问nginx怎么安装证书

笔记
  • 28

百度教程,打开了nginx配置文件,但是找不到https Server,本人小白,在线等大神解答

回复
阅读 1.9k
1 个回答
    # HTTPS server
    
    server {
        listen       443 ssl;
        server_name  你的域名;

        location 项目路径/ {
            root   html;
            index  index.php index.html index.htm;
        }

        ssl on;
        ssl_certificate 证书路径/ssl-unified.crt;
        ssl_certificate_key 私匙路径/de_ssl.key;
        
        ssl_session_cache    shared:SSL:20m;
        ssl_session_timeout  60m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
    }

然后再将http请求转到https

server {
  listen      80;
  server_name 你的域名;
  rewrite ^/(.*)$ https://你的域名/$1 permanent;
}
宣传栏