多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


相关推荐
汤愈韬5 小时前
ACL概述、ACL原理、基本ACL应用及配置
网络·网络协议·网络安全
小二李7 小时前
第11章 nestjs服务端开发:登录鉴权
运维·服务器
i建模8 小时前
如何在Arch Linux中重设忘记的root密码
linux·运维·服务器
何中应11 小时前
vmware的linux虚拟机如何设置以命令行方式启动
linux·运维·服务器
haluhalu.11 小时前
Linux网络编程------网络基础
网络·网络协议
坐怀不乱杯魂11 小时前
Linux网络 - HTTP协议
网络·网络协议·http
野犬寒鸦11 小时前
从零起步学习并发编程 || 第一章:初步认识进程与线程
java·服务器·后端·学习
百炼成神 LV@菜哥11 小时前
Kylin Linux V10 aarch64 安装启动 TigerVNC-Server
linux·服务器·kylin
m0_7373025811 小时前
百度智能云边缘云服务器,端云协同赋能全域智能场景
服务器
Anastasiozzzz12 小时前
LeetCode Hot100 295. 数据流的中位数 MedianFinder
java·服务器·前端