cundeng 发表于 2018-11-9 06:14:32

Nginx配合keepalived实现LVS负载均衡--生产环境实际案例

user nginx;  
worker_processes 8;
  
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
  
error_log /data/log/error.log debug;
  
pid /data/webserver/nginx/logs/nginx.pid;
  
worker_rlimit_nofile 65535;
  
   events {
  
   use epoll;
  
   worker_connections 65535;
  
          }
  
    http {
  
         include mime.types;
  
         default_type application/octet-stream;
  
         charset utf-8;
  
         server_names_hash_bucket_size 128;
  
         client_header_buffer_size 32k;
  
         large_client_header_buffers 4 32k;
  
         client_max_body_size 50m;
  
         sendfile on;
  
         tcp_nopush on;
  
         keepalive_timeout 60;
  
         tcp_nodelay on;
  
         server_tokens off;
  
         fastcgi_connect_timeout 300;
  
         fastcgi_send_timeout 3000;
  
         fastcgi_read_timeout 3000;
  
         fastcgi_buffer_size 64k;
  
         fastcgi_buffers 4 64k;
  
         fastcgi_busy_buffers_size 128k;
  
         fastcgi_temp_file_write_size 128k;
  
         gzip on;
  
         gzip_min_length 1k;
  
         gzip_buffers 416k;
  
         gzip_http_version 1.0;
  
         gzip_comp_level 2;
  
         gzip_types text/plain application/x-javascript text/css application/xml;
  
         gzip_vary on;
  
         log_format access '\$remote_addr - \$remote_user [\$time_local] "\$request" ' '\$status \$body_bytes_sent "\$http_referer" '
  
         '"\$http_user_agent" "\$http_x_forwarded_for" - "\$http_soapaction"';
  
            server
  
                {
  
                   listen 80;
  
                   server_name 0.0.0.0; #webserver外网ip
  
                   index index.html index.php;
  
                   root   /data/www/cloudservice/;
  
                  #autoindex on;
  
                   location = /favicon.ico {
  
                   log_not_found off;
  
                   access_log off;
  
                   }
  
                  location /Framework/tvos/ {
  
                         try_files \$uri \$uri/ /Framework/tvos/index.php?\$args;
  
                  }
  
                  # nginx status
  
                  location /coocaa_status {
  
                  stub_status on;
  
                  access_log /data/log/nginx_status.log;
  
                  auth_basic "NginxStatus";
  
                  allow 192.168.0.58;
  
                  deny all;
  
                  }
  
                  location ~ \.php$ {
  
                  root         /data/www/cloudservice;
  
                  fastcgi_pass   127.0.0.1:9000;
  
                  fastcgi_indexindex.php;
  
                  fastcgi_paramSCRIPT_FILENAME/data/www/cloudservice/$fastcgi_script_name;
  
                  include      fastcgi_params;
  
                  }
  
               location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)\$
  
               {
  
               expires 30d;
  
               }
  
               location ~ .*\.(js|css)?\$
  
               {
  
               expires 1h;
  
               }
  
             access_log /data/log/access.log access;
  
         }
  
    }


页: [1]
查看完整版本: Nginx配合keepalived实现LVS负载均衡--生产环境实际案例