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

    大家一起来学习
  • 相关阅读:
    mysqladmin
    Android project structure in Eclipse
    Android System Architecture
    The Origins of Data Mining
    Ubuntu 12.04 ‘can not lock /etc/shadow try again later’
    20122013QS计算机专业世界大学排名
    What is Data Mining
    HOW to login MYSQL, Help, and Select Database
    C++函数指针与C#委托之间有何联系
    How to download codes from Google Code
  • 原文地址:https://www.cnblogs.com/cuibobo/p/5346722.html
Copyright © 2011-2022 走看看