多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


相关推荐
网络工程小王38 分钟前
【LCEL 链式调用详解】调用篇-2
java·服务器·前端·数据库·人工智能
Deitymoon1 小时前
ESP8266——TCP客户端
网络·网络协议·tcp/ip
xhbh6662 小时前
路由端口转发常见应用场景有哪些?有什么?
服务器·ip·端口转发·ip地址·流量转发·建站
宁小法2 小时前
Linux批量删除文件
linux·服务器·批量·删除文件
zhangfeng11333 小时前
适合 5人以内小团队的Git 工作流 + Code Review + 自动化部署方案 FastAdmin +linunx服务器宝塔系统 外包项目 —
服务器·git·自动化·php·代码复审
北冥湖畔的燕雀3 小时前
Linux线程编程核心指南
linux·服务器·网络
倔强的石头1063 小时前
【Linux 指南】文件系统系列(一):磁盘底层原理 —— 从物理结构到 CHS与LBA 寻址全解析
linux·运维·服务器
小金的学习笔记4 小时前
小白打造个人博客的神奇秘诀:WordPress 竟如此简单?
服务器
Deitymoon4 小时前
ESP8266——透传
单片机·网络协议·tcp/ip