多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 分钟前
UDP编程
网络·网络协议·udp
Lily.C4 分钟前
小程序WebSocket实时通信全解析
websocket·网络协议·小程序
一水鉴天4 分钟前
整体设计 定稿 之 34 codybuddy项目跨机同步方案 之2 (codebuddy)
服务器·前端
代码游侠6 分钟前
学习笔记——TCP 传输控制协议
linux·网络·笔记·网络协议·学习·tcp/ip
ICT技术最前线9 分钟前
华为交换机VLAN配置命令详解
服务器·网络·vlan·华为交换机
zhendianluli10 分钟前
为什么fclose处理的是file而不是fd
linux·服务器·网络
牙牙70510 分钟前
部署SFTP服务
linux·服务器·网络
人工智能训练10 分钟前
Ubuntu 系统安装 VSCode 超全指南(3 种方法,适配 20.04/22.04 LTS)
linux·运维·服务器·vscode·ubuntu
TG:@yunlaoda360 云老大12 分钟前
华为云国际站代理商的CloudPond跨境主要有什么用呢?
服务器·网络·华为云
facaixxx202412 分钟前
GPU算力租赁:3080Ti、Tesla P40和RTX40服务器配置整理
运维·服务器·gpu算力