zoukankan      html  css  js  c++  java
  • nginx使用https协议

    效果:

    nginx添加ssl模块

    ./configure  --with-http_ssl_module
    

    生成证书

    openssl genrsa -out ca.key 2048
    openssl req -new -x509 -days 1096 -key ca.key -out ca.crt
    

    配置文件

    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
    
        server {
            listen       80;
            server_name  localhost;
    
            location / {
                root   html;
                index  index.html index.htm;
    	    return 301 https://$server_name$request_uri;
            }
    
        }
    
    
    
        # HTTPS server
    
        server {
            listen       443 ssl;
            server_name  localhost;
    
            ssl_certificate      ca/ca.crt;
            ssl_certificate_key  ca/ca.key;
    
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
    
            ssl_ciphers  HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers  on;
    
            location / {
                root   html;
                index  index.html index.htm;
            }
        }
    
    }
    

    启动

    ./sbin/nginx -c conf/ca.conf
    
  • 相关阅读:
    Day 18
    Day 17
    Day 16
    Day 15
    Day 14
    Day 13
    Day 12
    Day 11
    Day 10
    《ES6标准入门》(阮一峰)--2.let 和 const 命令
  • 原文地址:https://www.cnblogs.com/lanqie/p/8820638.html
Copyright © 2011-2022 走看看