疯狂

STANDING ON THE SHOULDERS OF GIANTS
posts - 481, comments - 486, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Nginx tomcat负载配置

Posted on 2011-02-15 23:08 疯狂 阅读(644) 评论(0)  编辑  收藏 所属分类: 架构

Nginx.conf :

user  oschina;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    use epoll;
    worker_connections  2048;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] $request '
    #                  '"$status" $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  off;
    access_log  logs/access.log;

    client_header_timeout  3m;
    client_body_timeout    3m;
    send_timeout           3m;
 
    client_header_buffer_size    1k;
    large_client_header_buffers  4 4k;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    #keepalive_timeout  75 20;

    include    gzip.conf;
   
    server {
    listen 80;
    server_name .oschina.net;
    location / {
        rewrite (.*) http://www.test.net$1 permanent;
    }
    }

    server {
    listen 80;
    server_name www.test.net;

        log_format  oschina_log
        '$remote_addr - $remote_user [$time_local] $request '
        '"$status" $body_bytes_sent "$http_referer" '
        '"$http_user_agent" "$http_x_forwarded_for"';
        access_log  logs/oschina.log;

    location ~ ^/(WEB-INF)/ {
            deny all;
        }

        location ~ \.(apk|torrent|htm|html|asp|php|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|mid|doc|ppt|xls|pdf|txt|mp3|wma)$ {
            root /data/oschina/webapp;
        access_log off;
            expires 24h;
        }
       
    location ~ ^/uploads/ {
        access_log off;
            root /data/test/webapp;
        expires 24h;
        }

    location / {
        proxy_pass http://localhost:8080;
        include proxy.conf;
    }

    error_page 502 503 /502.html;
        error_page 404 /404.html;
    error_page 403 /403.html;
    }
}

gzip.conf:

gzip              on;
gzip_min_length      1000;
gzip_types         text/plain text/css application/x-javascript;

proxy.conf:

proxy_redirect          off;
proxy_set_header        Host $host;
proxy_set_header        X-Real-IP $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   300;
proxy_send_timeout      300;
proxy_read_timeout      300;
proxy_buffer_size       4k;
proxy_buffers           4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;


只有注册用户登录后才能发表评论。


网站导航: