多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


相关推荐
万山寒7 小时前
linux日志查询,查找某个关键词后面的内容
linux·运维·服务器
小贾要学习7 小时前
【Linux】TCP网络通信编程
linux·服务器·网络·c++·网络协议·tcp/ip
Q3_SkyAsh7 小时前
【电子取证】——第三届“平航杯”电子数据取证竞赛服务器取证部分
服务器·电子取证
大白菜和MySQL7 小时前
apache服务器部署简记
运维·服务器·apache
渣渣馬8 小时前
rk3588s的firfly的linux的sdk版本
linux·运维·服务器
Hello_Embed8 小时前
嵌入式上位机开发入门(十九):Socket 状态检测与断线重连
网络·单片机·网络协议·tcp/ip·嵌入式
大数据新鸟9 小时前
NIO 三大核心组件
服务器·网络·nio
Hello World . .9 小时前
Linux驱动编程1:imxull上移植Linux系统
linux·运维·服务器
添砖java‘’9 小时前
网络层IP
网络·网络协议·tcp/ip·ip
IMPYLH9 小时前
Linux 的 numfmt 命令
linux·运维·服务器·bash