zoukankan      html  css  js  c++  java
  • nginx 虚拟主机

    环境:2台web服务器,1台nginx服务器,1台客户端

    1、配置2台web服务器(关闭iptables,关闭selinux)

    yum -y install  httpd

    service httpd start

    exho  "192.168.1.10"  >  /var/www/html/index.html

    exho "192.168.1.100"  >  /var/www/html/index.html

    分别各在本机测试访问

    2、配置nginx服务器

    http {     include       mime.types;    

         default_type  application/octet-stream;   

         upstream myserver  {                    #定义源服务器组  

         ip_hash;   //给同一用户分配固定服务器(ip_hash和weight不能同时使用)        

         server  192.168.1.10 weigth=3;//权重服务器        

          server  192.168.1.20;  server  192.168.1.30 down; //宕机服务器  (宕机就不能用了,就不调用该机)  

         server  192.168.1.40 backup;//备份/用服务器  

                server  192.168.1.50 max_fails=3  fail_timeout=30; //有三次连接失败,则宕机30秒      }    

        server {         listen       80;        

              server_name  www.163.com;   #web主机名        

          location / {            

              index  index.html index.htm;        

              proxy_pass  http://myserver;     #调用服务器组 }

    }

    /usr/lcoal/nginx/sbin/nginx  -s  reload

    3、客户端:vim /etc/hosts

    192.168.1.254 www.163.com

    大家一起来学习
  • 相关阅读:
    layui框架如何在停止服务用户操作任何步骤自动跳转登录页
    h5移动端和ios以及安卓客户端的接口联调
    sublime 主要使用方法
    内外边距、浮动、布局相关
    js介绍
    css的三个特性 背景透明设置
    选择器 导航制作相关
    表单综合
    自定义列表dl
    相对路径和绝对路径
  • 原文地址:https://www.cnblogs.com/cuibobo/p/5346722.html
Copyright © 2011-2022 走看看