814247614 发表于 2018-11-13 12:36:14

keepalived(nginx)+httpd实现动静分离

usernginx;  
worker_processes1;
  

  
error_log/var/log/nginx/error.log warn;
  
pid      /var/run/nginx.pid;
  

  

  
events {
  
    worker_connections1024;
  
}
  

  
http {
  
    include       /etc/nginx/mime.types;
  
    default_typeapplication/octet-stream;
  

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

  
    access_log/var/log/nginx/access.logmain;
  
    sendfile      on;
  
    keepalive_timeout65;
  
    include /etc/nginx/conf.d/*.conf;
  

  
    upstream websrvs {             #后端静态资源服务器
  
         server 172.16.61.1 weight=1 max_fails=2 fail_timeout=6s;
  
         ip_hash;
  
    }
  
    upstream phpsrvs {             #后端动态资源服务器
  
         server 172.16.100.123 weight=1 max_fails=2 fail_timeout=6s;
  
         ip_hash;
  
    }
  
   server {
  
         listen 80;
  
         root /data/www/vhost1/;
  
         server_name www.tz.com;
  
         index index.phpindex.html;
  
         location / {
  
            proxy_pass         #静态资源统一调度到此组服务器
  
            proxy_set_header Host $host;
  
            proxy_set_header X-Forwarded-For $remote_addr;
  
         }
  
         location ~* \.php$ {                   #动态资源统一调度到此组服务器
  
            proxy_pass http://phpsrvs;
  
            proxy_set_header Host $host;
  
            proxy_set_header X-Forwarded-For $remote_addr;
  
         }
  
    }
  
}


页: [1]
查看完整版本: keepalived(nginx)+httpd实现动静分离