lihu129c 发表于 2018-11-11 08:18:41

构建高可用服务器之四 Keepalive冗余Nginx-Just For Fun!

# cat/usr/local/nginx/conf/nginx.conf  
worker_processes1;
  

  
events {
  
   worker_connections1024;
  
}
  

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

  
   sendfile      on;
  
   keepalive_timeout65;
  
###############################################################################
  
upstream discuz {
  
                server 192.168.1.3:80 weight=1max_fails=2 fail_timeout=30s;
  
                server 192.168.1.4:80 weight=1max_fails=2 fail_timeout=30s;
  
                        }
  

  
   server {
  
       listen       80;
  
       server_namelocalhost;
  

  
         location/ {
  
          root   html;
  
          indexindex.html index.htm;
  
                proxy_set_header Host $host;
  
                proxy_set_header X-Real-IP$remote_addr;
  
                proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
  
                proxy_pass http://discuz;
  
       }
  
################################动静分离#######################################
  

  
         location~ .*\.(php|jsp|cgi|shtml)?$
  
             {
  
               proxy_set_header Host$host;
  
               proxy_set_header X-Real-IP$remote_addr;
  
               proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
  
               proxy_pass http://discuz;
  
             }
  

  
      location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
  
             {
  
                   root/usr/local/nginx/html;
  
                   expires      30d;
  
       }
  
#######################################################################
  
       error_page   500 502 503 504/50x.html;
  
       location = /50x.html {
  
         root   html;
  
       }
  

  
    }
  

  
}
  
#


页: [1]
查看完整版本: 构建高可用服务器之四 Keepalive冗余Nginx-Just For Fun!