多ip访问网站

多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_name
        root /test/100;
        location / {
                index index.html;
        }
}
server{
        listen 192.168.36.200:80;
        #server_name
        root /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

请添加图片描述
请添加图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值