tomcat+nginx部署多个项目相关配置

有时申请不下公司服务器资源,那就只能将就一下挤一挤了,生产、测试环境等多个项目部署在同一服务器;html

无需安装多个ngin,修改nginx配置文件便可,Linux路径:/usr/local/nginx/conf/nginx.conf前端

代码里,有三个服务,nginx

监听端口分别是80、8一、82tomcat

前端代码都放在/app/WebServer服务器

后台项目名分别是 ntp、(.do是默认)、test_ytfs app

传递路径分别是 http://127.0.0.1:8080、http://127.0.0.1:80十、http://127.0.0.1:8011;不通端口分别被三个tomcat接收测试

server {
        listen       80;
        server_name  localhost;
		root  /app/WebServer;
		
        location / {
            root   /app/WebServer/;
            index  index.html index.htm;
        }
		
        error_page   500 502 503 504  /50x.html;
		
        location = /50x.html {
            root   html;
        }
		
        location ~ /ntp {
						proxy_pass   http://127.0.0.1:8080;
						proxy_read_timeout 300s;
        }
        
    }
	
	server {
        listen       81;
        server_name  localhost;
        root  /app/WebServer;
		
        location / {
            root   /app/WebServer/;
            index  index.html index.htm;
        }
		
       error_page   500 502 503 504  /50x.html;
	   
        location = /50x.html {
            root   html;
        }
        
		location ~ \.do$ {		
            proxy_pass   http://127.0.0.1:8010;
						 proxy_read_timeout 300s;
        }
    }
	
	server {
        listen       82;
        server_name  localhost;
        root  /app/WebServer;
		
        location / {
            root   /app/WebServer/;
            index  index.html index.htm;
        }
       error_page   500 502 503 504  /50x.html;
	   
        location = /50x.html {
            root   html;
        }
        
		location ~ /test_ytfs {
            proxy_pass   http://127.0.0.1:8011;
						 proxy_read_timeout 300s;
        }
    }

3个tomcat  server.xml文件配置以下code

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<Connector connectionTimeout="20000" port="8010" protocol="HTTP/1.1" redirectPort="8444"/>
<Connector connectionTimeout="20000" port="8011" protocol="HTTP/1.1" redirectPort="8445"/>

安装多个tomcat就很少说了,资料太多;server