0
回答
nginx tomcat 二级域名 在线求解决
华为云4核8G,高性能云服务器,免费试用   

2个配置文件,tomcat1.conf和tomcat2.conf,服务器安装了3个tomcat,127.0.0.1:8080,127.0.0.1:8090,127.0.0.1:8097

配置文件如下

upstream tomcat1 {
	server 127.0.0.1:8080 weight=1;
	server 127.0.0.1:8090 weight=1;
    }

    server {
        listen       80;
        server_name  wx.xxxxxx.com wh.xxxxxx.com;

	if ($http_user_agent ~ "JikeSpider|Indy Library|Alexa Toolbar|bingbot|AskTbFXTV|AhrefsBot|CoolpadWebkit|Microsoft URL Control|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|curl" )
	{
		return 403;
	}

        location / {
           proxy_pass http://tomcat1;
	   proxy_redirect          off;
	   proxy_set_header        Host $host;
           proxy_set_header        X-Real-IP $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        } 
	
	
    }



server {
        listen       80;
        server_name  wk.xxxxxx.com;

	if ($http_user_agent ~ "JikeSpider|Indy Library|Alexa Toolbar|bingbot|AskTbFXTV|AhrefsBot|CoolpadWebkit|Microsoft URL Control|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|curl" )
	{
		return 403;
	}

        location / {
           proxy_pass http://127.0.0.1:8097;
           proxy_redirect          off;
	   proxy_set_header        Host $host;
           proxy_set_header        X-Real-IP $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }  
    }



2个配置文件都丢在conf.d文件夹中

访问wx.xxxxxx.cn,wh.xxxxxx.cn,wk.xxxxxx.cn都进入http://127.0.0.1:8097这个tomcat进行处理

如果删除tomcat2.conf这个配置文件

访问wx.xxxxxx.cn,wh.xxxxxx.cn,wk.xxxxxx.cn应该是tomcat1.conf生效,8080和8090的tomcat处理


求解答,为何会这样,我配置文件写错了吗?为何tomcat1.conf和tomcat2.conf都放入conf.d文件夹时候,wx,wh不走8080和8090这边


不知道问题描述清楚木有

举报
jeffw
发帖于4年前 0回/192阅
顶部