nginx 虚拟主机+负载均衡

worker_processes  2;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    #nginx vhosts config

  upstream rest_lc {

   #ip_hash; 

    server 192.168.1.240:8080 ;

    server 192.168.1.244:8080 ;

   #sticky name=srv_id expires=1h domain=www.lc.com path=/ ;

  }

  upstream wap_lc {

   #ip_hash;  

    server 192.168.1.240:8081 ;

    server 192.168.1.244:8081 ;

   #sticky name=srv_id expires=1h domain=www.lc.com path=/ ;

  }

  upstream activity_lc {

   #ip_hash;  

    server 192.168.1.244:8082 ;

    server 192.168.1.240:8082 ;

   #sticky name=srv_id expires=1h domain=www.lc.com path=/ ;

  }

    server{

    server_name rest.lc.in;

    listen  80;

    location / {

    root /home/tomcat/tomcat-rest;

    proxy_pass       http://rest_lc;

    proxy_set_header Host        $host;

    proxy_set_header X-Forwarded-For $remote_addr ;

    }

    }

    server{

        listen  80;

    server_name wap.lc.in;

    location / {

    root /home/tomcat/tomcat-wap;

    proxy_pass       http://wap_lc;

    proxy_set_header Host        $host;

    proxy_set_header X-Forwarded-For $remote_addr ;

    }

    }

    server{

    listen  80;

    server_name activity.lc.in;

    location / {

    root /home/tomcat/tomcat-activity;

    proxy_pass       http://activity_lc;

    proxy_set_header Host        $host;

    proxy_set_header X-Forwarded-For $remote_addr ;

    }


}

}


你可能感兴趣的:(nginx,负载均衡,虚拟主机)