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

    大家一起来学习
  • 相关阅读:
    51nod乘积之和
    Dell服务器安装OpenManage(OMSA)
    Nginx反向代理PHP
    搭建haproxy
    108. Convert Sorted Array to Binary Search Tree
    60. Permutation Sequence
    142. Linked List Cycle II
    129. Sum Root to Leaf Numbers
    118. Pascal's Triangle
    26. Remove Duplicates from Sorted Array
  • 原文地址:https://www.cnblogs.com/cuibobo/p/5346722.html
Copyright © 2011-2022 走看看