Centos nginx 负载均衡+动静分离配置

    upstream tomcat_server {    
        server 192.168.1.231:8080 weight=1;    
        server 192.168.1.232:8080 weight=1;    
    }

	location  / {  
	   proxy_set_header  Host $host;  
	   proxy_set_header  X-Real-IP  $remote_addr;  
	   proxy_pass http://tomcat_server;   
	}
	
	#动态访问转向tomcat处理
	#location ~ \.(jsp|page|do)?$ {  
	#   proxy_set_header  Host $host;  
	#   proxy_set_header  X-Real-IP  $remote_addr;  
	#   proxy_pass http://tomcat_server;   
	#}  
	   
	#设定访问静态文件直接读取不经过tomcat
	location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$  {   
	   expires      30d;       
	}        
	location ~ .*\.(js|css)?$ {  
	   expires      1h;  
	} 

Nginx常用配置:
https://juejin.im/post/5d7e3f51f265da03a31d687b

你可能感兴趣的:(Linux)