多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 小时前
【已解决】报错:WARNING: pip is configured with locations that require TLS/SSL
网络协议·ssl·pip
白鸽梦游指南1 小时前
RHCE模拟测试
linux·运维·服务器
herderl2 小时前
【无标题】命名管道(Named Pipe)是一种在操作系统中用于**进程间通信(IPC)** 的机制
java·linux·服务器·嵌入式硬件·php
哈基米喜欢哈哈哈4 小时前
计算机网络(一)——TCP
网络·tcp/ip·计算机网络
suwith4 小时前
nginx高新能web服务器
linux·服务器·nginx
重启的码农6 小时前
ZeroTier 源码解析 (6) 数据包 (Packet)
c++·网络协议
重启的码农6 小时前
ZeroTier 源码解析 (7) 拓扑 (Topology)
c++·网络协议
搬码临时工7 小时前
使用frp内网穿透实现远程办公
服务器·网络
鹧鸪云光伏7 小时前
[鹧鸪云]光伏AI设计平台解锁电站开发新范式
运维·服务器·人工智能·光伏·光伏设计
Zfox_7 小时前
Redis应⽤-缓存与分布式锁
服务器·数据库·redis·分布式·缓存