• Linux:使用ssl加密网站为https


    Linux:使用ssl加密网站为https

    生成对应的数字证书以及密钥

    [root@server100 ~]# openssl req -newkey rsa:2048 -nodes -sha256 -keyout /etc/nginx/certs/timinglee.org.key -x509 -days 365 -out /etc/nginx/certs/timinglee.org.crt
    
    ......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.......+.+......+..+......+......+.+..+.+............+...+...........+...+............+.+.....+...+..........+.........+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+....+........................+.........+.....+......+.......+.........+.....+...+..........+....................+.+..+...............+....+...+...+...+....................+.+.....+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ..+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*............+................+...+.........+..+...+.......+.....+.+..+.+..+..........+.........+......+.....+...+......+...+.+...........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+.......+.....+.......+...+..............+......+........................+...+...............+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [XX]:china
    String too long, must be at most 2 bytes long
    Country Name (2 letter code) [XX]:shannxi
    String too long, must be at most 2 bytes long
    Country Name (2 letter code) [XX]:86
    State or Province Name (full name) []:shannxi
    Locality Name (eg, city) [Default City]:xian
    Organization Name (eg, company) [Default Company Ltd]:openlab
    Organizational Unit Name (eg, section) []:RHCE
    Common Name (eg, your name or your server's hostname) []:shanxin
    Email Address []:123@alis.com
    
    [root@server100 ~]# cat /etc/nginx/certs/timinglee.org.key
    
    [root@server100 ~]# cat /etc/nginx/certs/timinglee.org.crt
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    配置虚拟主机基于https访问

    [root@server100 ~]# vim /etc/nginx/conf.d/vhosts.conf
    
    server{
            listen 443 ssl;
            server_name login.timinglee.org;
            ssl_certificate "/etc/nginx/certs/timinglee.org.crt";
            ssl_certificate_key "/etc/nginx/certs/timinglee.org.key";
            root /usr/share/nginx/virtual/login;
            index index.html;
    }
    
    [root@server100 ~]# nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    [root@server100 ~]# systemctl restart nginx.service
    [root@server100 ~]# mkdir -p /usr/share/nginx/virtual/login
    [root@server100 ~]# echo 'login.timinglee.org' > /usr/share/nginx/virtual/login/index.html
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    使用firefox浏览器测试

  • 相关阅读:
    内核与协议无关接口层的实现
    酱菜产业:传承美味,点亮生活
    一分钟了解期权合约转仓交易的流程
    怎么能还不会2PC、3PC?赶快学起来
    JAVA线程池
    精心准备200题Java相关面试,友情分享
    8/5 基础思维(div2 A、B、C、D)+dp+AC自动机
    Js----Math
    WebService SOAP1.1 SOAP1.12 HTTP PSOT方式调用
    808协议是指中国国标GB/T 32960-2017《道路车辆运行数据远程监管与服务》通信协议,也被称为JT/T808协议
  • 原文地址:https://blog.csdn.net/fox_kang/article/details/138218346