多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 小时前
什么是权威解析服务器?权威解析服务器哪些作用?
服务器·git·github
七灵微1 小时前
【后端】单点登录
服务器·前端
Orlando cron2 小时前
Kubernetes 网络模型深度解析:Pod IP 与 Service 的负载均衡机制,Service到底是什么?
网络·tcp/ip·kubernetes
xuanwojiuxin6 小时前
linux panic-propagation
linux·运维·服务器
achene_ql8 小时前
select、poll、epoll 与 Reactor 模式
linux·服务器·网络·c++
黎相思8 小时前
应用层自定义协议与序列化
运维·服务器·网络
邪恶的贝利亚9 小时前
实现p2p的webrtc-srs版本
网络协议·webrtc·p2p
Lightning-py10 小时前
Linux命令cat /proc/net/snmp查看网络协议层面统计信息
网络·网络协议·tcp/ip
2501_9151063210 小时前
iOS性能调优实战:借助克魔(KeyMob)与常用工具深度洞察App瓶颈
websocket·网络协议·tcp/ip·http·网络安全·https·udp
jllllyuz10 小时前
如何为服务器生成TLS证书
运维·服务器·数据库