Nginx+Tomcat配置转发到不一样域名下的不一样项目

本人新手,胡乱搞的,喷能够,可是轻一点,我怕痛。nginx

应届毕业生上班第二周,此为背景,华丽的分割线。web

-----------------------------------------------------------------tomcat

公司服务器上,跑着3个项目,tomcat1上跑一个,tomcat2上跑着两个,并且访问地址都是:服务器

        http://www.xxoo.com:port/project/app

        域名:端口/项目名webapp

因为是一台服务器,并且是不一样tomcat,tomcat下又有不一样项目,老板说的是须要直接根据域名就能够访问。本人玩过Apache服务器,配置起来不是很顺畅,因此就使用了nginx作端口转发,tomcat作项目区分,具体配置以下(nginx参照osc的):spa

server{
    listen    80;
    server_name    localhost;
    location / {
        deny all;
    }
    
    location ~ ^ /nginx_status {
        stub_status on;
        access_log off;
        allow 127.0.0.1;
        deny all;
    }
}

server {
    listen    80;
    server_name  www.xxoo1.com;
    location / {
        proxy_pass xxxx.xxxx.xxxx.xxxx:8081;
        include proxy.conf;
    }
    
    location ~ ^/WEB-INF {
        deny    all;
    }
 
}

server {
    listen       80;
    server_name  www.xxoo2.com;
    location / {
        proxy_pass xxxx.xxxx.xxxx.xxxx:8080;
        include proxy.conf;
    }
    
    location ~ ^/WEB-INF {
        deny    all;
    }
 
}
  
code

貌似nginx只能够转发端口,不能作到根据项目名称转发,摆渡了几回,没搞定,因此,就对tomcat下手了。
server

具体配置以下:<Host name="localhost"  appBase="webapps"    unpackWARs="true" autoDeploy="true"    xmlValidation="false" xmlNamespaceAware="false">    <Context path="/" docBase="" reloadable="true"/></Host><Host name="www.xxoo1.com"  appBase="webapps"    unpackWARs="true" autoDeploy="true"    xmlValidation="false" xmlNamespaceAware="false">    <Context path="/project1" docBase="project1" reloadable="true"/></Host><Host name="www.xxoo2.com"  appBase="webapps"    unpackWARs="true" autoDeploy="true"    xmlValidation="false" xmlNamespaceAware="false">    <Context path="/project2" docBase="project2" reloadable="true"/></Host>额,大概就是这么个意思...
相关文章
相关标签/搜索