多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


相关推荐
su3174 分钟前
rap2部署
linux·运维·服务器
宁雨桥24 分钟前
WebSocket 完全指南:从原理到实战,搭建实时通信桥梁
网络·websocket·网络协议
xinxinhenmeihao25 分钟前
爬虫导致IP被封号了如何解封?
爬虫·网络协议·tcp/ip
skywalk816330 分钟前
阿里云服务器FreeBSD新系统从登录、配置到升级:从14.1升级到FreeBSD 14.3 Release
linux·服务器·阿里云·freebsd
草莓熊Lotso32 分钟前
Linux 基础开发工具入门:软件包管理器的全方位实操指南
linux·运维·服务器·c++·人工智能·网络协议·rpc
拾忆,想起39 分钟前
TCP滑动窗口:网络世界的“智能流量阀门”
java·网络·数据库·网络协议·tcp/ip·php·哈希算法
木木em哈哈1 小时前
有关于cnb自动化的脚本补全
服务器·开发语言·pygame
Mr_Xuhhh1 小时前
GUI自动化测试--自动化简单示例
运维·服务器·自动化
羑悻的小杀马特1 小时前
零成本自建私人知识库教学,Leanote+Cpolar 内网穿透,手机电脑随时同步,无需云服务器,效率翻倍!
运维·服务器·coplar·leanote
止水编程 water_proof1 小时前
Java--HTTP(上)
网络·网络协议·http