nginx的https的搭建

实验:

1.防火墙不能关闭,让其开放http协议https协议

2.该网站具备账户验证

3.测试https的搭建

创建虚拟主机的发布目录

root@server \~# mkdir -p /web/dsj

root@server \~# echo "Welcome" > /web/dsj/index.html
创建证书

创建非对称加密使用的私钥文件(可直接将证书安装到对应服务目录下)

root@server \~# openssl genrsa -out dsj.key

通过私钥文件生成证书文件

root@server \~# openssl req -new -key dsj.key -x509 -days 365 -out dsj.crt

req:申请创建证书(request);

-new:新的证书;

-key dsj.key:使用dsj.key这个密钥;

-509:此为测试证书;

-days:证书有效期

搭建一个https网站

将生成生成证书移动到nginx配置目录中

root@server \~# mv dsj.crt dsj.key /etc/nginx/

绑定虚拟主机和证书

root@server \~# vim /etc/nginx/nginx.conf

server{

listen 443 ssl;

server_name 192.168.131.100;

root /web/dsj;

ssl_certificate /etc/nginx/dsj.crt;

ssl_certificate_key /etc/nginx/dsj.key;

}

检查配置文件,然后加载配置文件

root@server \~# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

root@server \~# nginx -s reload

浏览器验证

搭建账户验证功能的网站

安装工具:httpd-tools

root@server \~# dnf install nginx httpd-tools -y

使用htpasswd关联dsj和网站

root@server \~# htpasswd -c /etc/nginx/passswd dsj

New password:

Re-type new password:

Adding password for user dsj

修改nginx的配置文件

root@server \~# vim /etc/nginx/nginx.conf

auth_basic "please input your passwd"; #登录提示

auth_basic_user_file /etc/nginx/passwd; #管理网站和密码文件

检查配置文件,然后加载配置文件

root@server \~# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

root@server \~# nginx -s reload

浏览器验证

相关推荐
sudebao点com14 小时前
一次“Google 能打开,FlexTV 打不开”的 DNS 故障排查:从 curl 超时到完整证据链
windows·macos·https·cdn·dns·nslookup·网络排错
ControlRookie19 小时前
第15篇_Client 04|GET、POST 和 Body 怎样保持一致
http·codesys·plc通信·controlrookie
啦啦啦啦啦zzzz1 天前
TCP协议详解
网络·网络协议·tcp/ip
月落汀兰1 天前
Linux Nginx全套实战通关|静态站点/虚拟主机/HTTPS/PHP/反向代理/七层负载均衡,每行命令逐参数拆解
linux·nginx·https
张小姐的猫1 天前
【Linux】网络编程 —— 传输层协议 TCP(下)
linux·运维·服务器·网络·tcp/ip·http·php
Little Tian1 天前
基于FPGA的UDP回环实验(二)----ARP模块
网络·网络协议·udp
K成长日志1 天前
BLE链路层--比特流处理
网络·物联网·网络协议·蓝牙·iot·ble·无线
zhao3266857511 天前
静态IP代理固定IP与动态IP的根本差异,账号操作安全性如何体现
网络·网络协议·tcp/ip
SendTomo2 天前
P2P文件传输工具对比:SendTomo vs send.wang
javascript·网络协议·webrtc·html5·p2p
qyyyyy5702 天前
英文技术标准和协议规范怎么读?RFC、接口规范与安全标准 PDF 翻译流程
网络协议·网络安全·机器翻译·csrf·技术美术