Linux:使用ssl加密网站为https

Linux:使用ssl加密网站为https

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

bash 复制代码
[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

配置虚拟主机基于https访问

bash 复制代码
[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

使用firefox浏览器测试

相关推荐
等风来不如迎风去14 分钟前
用你本地已有的私钥(private key)去 SSH 登录远程 Ubuntu 服务器
服务器·ubuntu·ssh
平平无奇。。。15 分钟前
版本控制器之Git理论与实战
linux·git·gitee·github
tomcsdn4120 分钟前
SMTPman高效稳定的smtp服务器使用指南解析
服务器·邮件营销·外贸开发信·邮件群发·域名邮箱·邮件服务器·红人营销
宇宙第一小趴菜20 分钟前
11 安装回忆相册
linux·运维·centos7·yum·回忆相册·kh_mod
艾莉丝努力练剑21 分钟前
【Linux指令 (二)】不止于入门:探索Linux系统核心与指令的深层逻辑,理解Linux系统理论核心概念与基础指令
linux·服务器·数据结构·c++·centos
conkl32 分钟前
Linux IP 网络配置与管理详解
linux·网络·tcp/ip
ZhiqianXia1 小时前
Linux 内核中控制调试输出的频率和次数
linux
tjsoft1 小时前
设置 windows nginx.exe 每天 重启
运维·windows·nginx
星源~1 小时前
Linux-Ubuntu系统安装特别指导
linux·qt·ubuntu·嵌入式开发·物联网设备
读书读傻了哟1 小时前
Windows 10 使用 VMware Workstation 搭建 Ubuntu 虚拟机
linux·windows·ubuntu