电光石火-穿越时空电光石火-穿越时空


配置nginx.conf实现负载均衡

编辑/usr/local/nginx/conf/nginx.conf

http  

          include       mime.types; 
          default_type  application/octet-stream;      
          server_names_hash_bucket_size 128; 
          client_header_buffer_size 32k; 
          large_client_header_buffers 4 32k; 
          client_max_body_size 8m; 
          sendfile on; 
          keepalive_timeout 60; 
          gzip on; 
 
#负载均衡
upstream tomcat_proxy{
          server localhost:8080 max_fails=3 weight=1 fail_timeout=60s;
          server localhost:9080 max_fails=3 weight=1 fail_timeout=60s;
        }
       
server
  {
         listen       80;
         server_name  www.abc.com;           
         index index.jsp index.php index.do index.jsp;
         access_log  logs/www.abc.com_access_nginx.log;
         error_log logs/www.abc.com_error.log;
         root  /var/www/nginx;    #nginx默认根目录
    location ~ \.(php|php5)$ {        #支持php
            fastcgi_pass  unix:/var/run/php-fpm.sock;    #php-fpm.sock模块
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            include fastcgi_params;
            include fastcgi.conf;
            }
    location ~ \.(jsp|do)$ {        #jsp,do等页面交由tomcat处理
            proxy_pass tomcat_proxy;
            proxy_set_header HOST $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
            expires      30d;
            }
}

 

本博客所有文章如无特别注明均为原创。作者:似水的流年
版权所有:《电光石火-穿越时空》 => 配置nginx.conf实现负载均衡
本文地址:http://ilkhome.cn/index.php/archives/120/
欢迎转载!复制或转载请以超链接形式注明,文章为 似水的流年 原创,并注明原文地址 配置nginx.conf实现负载均衡,谢谢。

评论