欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 时评 > 服务器作业1

服务器作业1

2024/10/24 14:26:24 来源:https://blog.csdn.net/hhj123k/article/details/143096847  浏览:    关键词:服务器作业1

案例一:多ip访问多网站

关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0

添加多个ip地址
nmcli connection modify ens160 ipv4.method manual ipv4.addresses 192.168.115.100/24 +ipv4.addresses 192.168.115.200/24 ipv4.gateway 192.168.115.2 ipv4.dns 114.114.114.114
ip地址1 + IP地址2 gateway(网关地址)默认为192.168.115.2 dns 114.114.114.1414
激活IP地址
 nmcli connection up ens160 

激活前的IP地址:

激活新IP后重新连接虚拟机

ssh 192.168.115.100


编写子配置文件中的server模块
vim /etc/nginx/conf.d/test_ip.conf
进入文件后:
server{
    listen 192.168.115.100:80;#监听115.100IP地址
    #server name
    root /test/100;
    #location模块 /:网站根目录
    location / {
        index index.html;
    }

}

server{
        listen 192.168.115.200:80;
        #server name
        root /test/200;
        location / {
                index index.html;
        }

}


在test下创建100和200目录,多级目录加-pv选项
mkdir /test/{100,200} -pv

往100和200的index。html文件中添加内容
[root@localhost ~]# echo this is 100 > /test/100/index.html
[root@localhost ~]# echo this is 200 > /test/200/index.html

重启nginx服务
[root@localhost ~]# systemctl restart nginx

浏览器访问:


 

 

curl命令查看: 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com