多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


相关推荐
likfishdn8 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染10 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
chian-ocean28 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=30 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
橘子味的茶二39 分钟前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
一只小姜丝3321 小时前
解决各大浏览器中http地址无权限调用麦克风摄像头问题
网络·vue.js·网络协议·http
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
Tisfy5 小时前
LeetCode 1472.设计浏览器历史记录:一个数组完成模拟,单次操作均O(1)
服务器·leetcode·浏览器·memcached·题解·模拟·数组