nginx配置文件示範

tags:    時間:2014-03-23 13:52:19
nginx配置文件示例

測試配置文件見下:

# You may add here your # server { #	... # } # statements for each of your virtual hosts  server { 	listen   80; ## listen for ipv4 	#listen   [::]:80 default ipv6only=on; ## listen for ipv6  	server_name  yasi.app.chenwenbiao.com;  	access_log  /var/log/nginx/localhost.access.log;  	location ~ do$ { 		proxy_pass http://localhost:8080; 	}  	location /images { 		root   /usr/share; 	}  	#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   /var/www/nginx-default; 	#} }  server { 	listen   80; ## listen for ipv4 	#listen   [::]:80 default ipv6only=on; ## listen for ipv6  	server_name  kyjl.app.chenwenbiao.com;  	access_log  /var/log/nginx/kyjl_localhost.access.log;  	location ~ \.do$ { 		proxy_pass http://127.0.0.1:9081; 	}  	location ~ \.(gif|jpg|png|js|css|apk|ipa)$ { 		root  /home/web_deploy_workspace/lls/lls_project/lls/; 	} 	 	location ~ My97DatePicker\.htm$ { 		root  /home/web_deploy_workspace/lls/lls_project/lls/; 	} 	 	location  / { 		proxy_pass http://127.0.0.1:9081/download/kyjl.do; 	} }  server { 	listen 9080; 	location ~ { 			proxy_pass http://10.160.29.246:9080; 	} }   server { 	listen   80; ## listen for ipv4 	#listen   [::]:80 default ipv6only=on; ## listen for ipv6  	server_name  jyp.app.chenwenbiao.com;  	access_log  /var/log/nginx/fktc_localhost.access.log;  	location ~ \.do$ { 		proxy_pass http://127.0.0.1:9082; 	}  	location ~ \.(gif|jpg|png|js|css|apk|ipa)$ { 		root  /home/web_deploy_workspace/fktc/fktc_project/fktc/; 	} 	 	location ~ My97DatePicker\.htm$ { 		root  /home/web_deploy_workspace/fktc/fktc_project/fktc/; 	} 	 	location  / { 		proxy_pass http://127.0.0.1:9082/download/fktc.do; 	} }    server { 	listen   80; ## listen for ipv4 	#listen   [::]:80 default ipv6only=on; ## listen for ipv6  	server_name  yixin.app.chenwenbiao.com;  	access_log  /var/log/nginx/yixin_localhost.access.log;  	location ~ \.do$ { 		proxy_pass http://127.0.0.1:9083; 	} 	  	location ~ \.(gif|jpg|png|js|css|apk|ipa|resources)$ { 		root  /home/web_deploy_workspace/yixin/yixin_project/; 	} 	 	location ~ My97DatePicker\.htm$ { 		root  /home/web_deploy_workspace/yixin/yixin_project/; 	} 	 }           server { 	listen   80; ## listen for ipv4 	#listen   [::]:80 default ipv6only=on; ## listen for ipv6  	server_name  tuhao.app.chenwenbiao.com;  	access_log  /var/log/nginx/tuhao_localhost.access.log;  	location ~ \.do$ { 		proxy_pass http://127.0.0.1:9084; 	}  	location ~ \.(gif|jpg|png|js|css|apk|ipa)$ { 		root  /home/web_deploy_workspace/tuhao/tuhao_project/tuhao/; 	} 	 	location ~ My97DatePicker\.htm$ { 		root  /home/web_deploy_workspace/tuhao/tuhao_project/tuhao/; 	} 	 }       server { 	listen   80; ## listen for ipv4 	#listen   [::]:80 default ipv6only=on; ## listen for ipv6  	server_name  txwt.app.chenwenbiao.com;  	access_log  /var/log/nginx/txwt_localhost.access.log;  	location ~ \.do$ { 		proxy_pass http://127.0.0.1:9084; 	}  	location ~ \.(gif|jpg|png|js|css|apk|ipa)$ { 		root  /home/web_deploy_workspace/txwt/txwt_project/txwt/; 	} 	 	location ~ My97DatePicker\.htm$ { 		root  /home/web_deploy_workspace/txwt/txwt_project/txwt/; 	} 	 	location  / { 		proxy_pass http://127.0.0.1:9084/download/txwt.do; 	} }   server { 	listen   80; ## listen for ipv4 	#listen   [::]:80 default ipv6only=on; ## listen for ipv6  	server_name  yixinv2.app.chenwenbiao.com;  	access_log  /var/log/nginx/yixin_localhost.access.log;  	location ~ / { 		proxy_pass http://127.0.0.1:2346; 	}  	location ~ \.(gif|jpg|png|js|css|apk|ipa|resources)$ { 		root  /home/web_deploy_workspace/kyjl_web/apache-tomcat-7.0.42/webapps/qa-web/; 	} 	 	location ~ My97DatePicker\.htm$ { 		root  /home/web_deploy_workspace/kyjl_web/apache-tomcat-7.0.42/webapps/qa-web/; 	} 	 } 

 

放在/etc/nginx/sites-available/default文件里.使用nginx作中轉,將不同的請求打到不同的tomcat伺服器里。

 

推薦閱讀文章

Bookmark the permalink ,來源:互聯網