多個tomcat下Nginx的基礎配置

加入要配置多個tomcat那麼在server.xml中的三個端口號都要改,不然會引發端口衝突 

下面我將演示代理三個tomcat組成的集羣

要修改tomcat下的server.xml中的兩個端口

tomcat7的配置

tomcat8的配置 

tomcat9的配置

修改nginx中的conf.xml 

 

upstream mytomcat{
		server localhost:8081;	#tomcat7
		server localhost:8082;	#tomcat8
		server localhost:8083;	#tomcat9
	
	
	}
	
	server {
        listen       9999;		#監聽的域名或者端口號
        server_name  tomcat;	#這個名稱沒有什麼重大的意義,起一個標識

      
        location / {
           proxy_pass http://mytomcat;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
       
    }



重載Nginx配置
nginx -s reload

在沒有配置nginx下我的訪問方式爲

 

 配置了nginx後我的訪問方式爲

 

 

 

proxy_pass中的地址不要帶_下劃線,不然會有tomcat版本的原因造成錯誤

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章