我是靠谱客的博主 典雅麦片,这篇文章主要介绍Nginx配置Https,现在分享给大家,希望可以做个参考。


最近要求Nginx支持Https访问,然后研究了一下,发现配置其实还是很简单的。用的方案就是在之前的配置的server上面再套一层server,然后开启ssl即可。

之前是这个配置

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    
    server {
        listen       8981;
        server_name  localhost;
        
        client_max_body_size 2048M;
        index  index.html index.htm index.jsp;
        location / {
             try_files $uri $uri/ @router;
             index index.html;
         }
}



然后在服务器上用openssl生成密钥文件,之后在原来nginx配置上面套一层ssl配置代理一下。

server {
        listen       8982 ssl;
        server_name  localhost;
        
        client_max_body_size 2048M;
        index  index.html index.htm index.jsp;
        ssl_certificate      /root/card/domain.crt;
        ssl_certificate_key  /root/card/domain_nopass.key;
        
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
   
         location / {
            index  index.html index.htm;
            proxy_pass http://localhost:8981/;
        }
    }


————————————————

原文链接:https://blog.csdn.net/flash_love/article/details/122913119

最后

以上就是典雅麦片最近收集整理的关于Nginx配置Https的全部内容,更多相关Nginx配置Https内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(100)

评论列表共有 0 条评论

立即
投稿
返回
顶部