当前位置: 首页 > article >正文

服务器作业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命令查看: 


http://www.kler.cn/news/358625.html

相关文章:

  • 基于MATLAB车牌识别系统设计
  • R语言绘制Venn图(文氏图、温氏图、维恩图、范氏图、韦恩图)
  • SQL第19课——使用存储过程
  • 手机如何分享网络给电脑
  • @ResponseBody详细解释及代码举例
  • MiniConda 的安装与使用
  • RabbitMQ系列学习笔记(二)--简单模式
  • 基于SSM服装定制系统的设计
  • 学习docker第五弹------Docker容器数据卷
  • Python知识点:基于Python技术和工具,如何使用IPFS进行去中心化存储
  • 基于MATLAB HU不变矩的树叶识别系统
  • 基于python+dj+mysql的音乐推荐系统网页设计
  • 本地部署 mini-omni
  • 【火山引擎】语音识别 |流式语音识别 | python
  • 根据json转HttpClient脚本
  • 数据为何成为资产?
  • 92. Color颜色渐变插值
  • 【JDK、Maven、Git、PostgreSQL】VSCode后端开发环境配置样例
  • 数值优化 | 图解梯度下降法与共轭梯度下降法(附案例分析与Python实现)
  • 北斗导航系统在智能交通领域的应用