多ip访问网站
安装nginx
[root@localhost ~]# dnf install nginx -y
关闭防火墙,sulinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
添加多IP(这里使用图形化模式)
[root@localhost ~]# nmtui
[root@localhost ~]# nmcli connection up ens160
撰写配置文件
[root@localhost ~]# vim /etc/nginx/conf.d/test_ip.conf
server {listen 192.168.36.100:80;# server_nameroot /test/100;location / {index index.html;}
}
server{listen 192.168.36.200:80;#server_nameroot /test/200;location / {index index.html;}
}
创建存放ip显示内容的目录
[root@localhost ~]# mkdir /test/{100,200} -pv
像两个ip网页写入内容
[root@localhost ~]# echo this is 1 > /test/100/index.html
[root@localhost ~]# echo this is 2 > /test/200/index.html
重启nginx服务
[root@localhost ~]# systemctl restart nginx
测试
[root@localhost ~]# curl 192.168.36.100
this is 1
[root@localhost ~]# curl 192.168.36.200
this is 2