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浏览器测试

相关推荐
深圳恒讯几秒前
香港云主机硬盘满了怎么办?Linux和Windows在线扩容操作教程
linux·运维·windows
饭后一颗花生米3 分钟前
GitHub Actions 自动化:5 个真实运维提效案例
运维·自动化·github
十碗阳春面3 分钟前
阿里云 Ubuntu 22.04 部署 Flarum 论坛:从空白服务器到中文界面、公网 IP 访问
服务器·ubuntu·阿里云
Android系统攻城狮8 分钟前
Linux FFmpeg深度解析之av_parser_init调用流程与实战(二十一)
linux·运维·服务器·ffmpeg·音视频进阶·ffmpeg音视频
HideF25 分钟前
Linux 查看用户和组
linux
Canmag 兴隆磁性29 分钟前
钕铁硼磁片取向方向检测自动化方案:从人工目检到流水线在线分选的工程实践
运维·数据库·自动化·工业自动化·钕铁硼·自动化检测·磁材料
a59865230 分钟前
ARM服务器搭建云手机靠谱吗?个人自建方案优缺点总结
服务器·arm开发·智能手机·云手机
寺中人40 分钟前
CentOS 7进程与任务管理
linux·运维·centos·服务器搭建与管理·linux运维命令·nohup screen
Hello.Reader1 小时前
100 人同时操作一座三维城市,为什么不需要服务器渲染 6000 帧?Rust + wgpu 多端并发架构实战
服务器·架构·rust
R²AIN SUITE1 小时前
多云或私有云环境怎么选项目管理工具?RainSuite等5种产品的8项部署验证
服务器·网络·数据库