nginx 代理多个tomcat缓存
nginx 代理多个tomcat缓存
一念三千 发表于2年前
nginx 代理多个tomcat缓存
  • 发表于 2年前
  • 阅读 126
  • 收藏 14
  • 点赞 0
  • 评论 0
摘要: nginx 缓存代理 多个tomcat


user  ftp;
worker_processes  2;




worker_rlimit_nofile 1024;
events {
    use epoll;
    worker_connections  1024;
}




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


    include       proxy.conf;
    log_format yundns_log '$server_name $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
    #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  logs/access.log  main;


    server_tokens off;
    sendfile        on;
    tcp_nopush     on;
    server_names_hash_bucket_size 256;
    client_header_buffer_size 256k;
    #large_client_header_buffers 4 32k;


    large_client_header_buffers 4 256k;
    client_body_buffer_size 256k;
    client_header_timeout     3m;
    client_body_timeout 3m;
    send_timeout             3m;


    client_max_body_size 50m;
    keepalive_timeout  120;
    fastcgi_intercept_errors on;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    #fastcgi_buffer_size 64k;
    #fastcgi_buffers 8 64k;
    #fastcgi_busy_buffers_size 128k;
    #fastcgi_temp_file_write_size 128k;


    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
   
    ##cache##
    proxy_connect_timeout 5;
    proxy_read_timeout 60;
    proxy_send_timeout 5;
    proxy_buffer_size 16k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;
    proxy_temp_path /home/temp_dir;
    proxy_cache_path /home/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
  ##end##






    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;


   server {
listen       81;


location /{
root /mnt;
index index.html index.htm;
client_body_buffer_size 128k;
}
    }



   server {
        listen       82;
        server_name  localhost;
        index index.jsp index.html;
root /mnt/wph;
         location ~ .*\.(gif|jpg|png|htm|html|css|js|flv|ico|swf)(.*) {
           proxy_pass http://localhost:8080;
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_cache cache_one;
           proxy_cache_valid 200 302 1h;
           proxy_cache_valid 301 1d;
           proxy_cache_valid any 1m;
           expires 30d;
       }
       location   /{               
                proxy_pass http://localhost:8080;
                proxy_set_header X-Real-IP $remote_addr;
          }
      }
 




 
 
    server {
        listen       80 default_server;
        server_name  localhost;


index index.jsp index.html;
root /mnt/default;
location ~ .*\.(gif|jpg|png|htm|html|css|js|flv|ico|swf)(.*) {
           proxy_pass http://localhost:9000;
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_cache cache_one;
           proxy_cache_valid 200 302 1h;
           proxy_cache_valid 301 1d;
           proxy_cache_valid any 1m;
           expires 30d;
       }
location ~ .* {
proxy_pass http://127.0.0.1:9000;
proxy_set_header X-Real-IP $remote_addr;
}
        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}


        #error_page  404              /404.html;


        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }


        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}


        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
}

共有 人打赏支持
一念三千
粉丝 12
博文 62
码字总数 34826
×
一念三千
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: