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

相关推荐
楼田莉子2 分钟前
Linux网络:IP协议
linux·服务器·网络·c++·学习·tcp/ip
极客on之路6 分钟前
线上 JVM 出问题
运维·服务器·jvm
wuminyu6 分钟前
专家视角看JVM_StartThread
java·linux·c语言·jvm·c++
敲上瘾10 分钟前
高并发内存池(三):PageCache(页缓存)的实现
linux·c++·缓存·高并发内存池·池化技术
HoneyMoose12 分钟前
Subversion 取代 CVS 后的 2026
运维
阿林爱吃大米饭12 分钟前
[AutoDL] 预防系统盘爆满:一键将Conda环境和Pip缓存迁移到数据盘(autodl-tmp)
服务器
Ops菜鸟(Xu JieHao)20 分钟前
Linux 内网远程桌面Xrdp ~保姆级教程
linux·运维·服务器·windows·远程桌面·远程·xrdp
zjeweler21 分钟前
linux服务器部署openclaw最新最细教程(非docker版)
linux·服务器·docker·openclaw
minglie124 分钟前
zynq裸机和linux spidev操作W25Q16
linux
运维 小白25 分钟前
2. vLLM多机单卡+open claw部署
运维·ai·vllm