带有tomcat的nginx子域

时间:2015-02-07 11:49:30

标签: tomcat nginx

我在tomcat server.xml中配置了这样的配置。

<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost">
    <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
    </Realm>
    <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
    </Host>
    <Host name="myapp.domain.com" appBase="myapp" unpackWARs="true" autoDeploy="true">
    </Host>
</Engine>

像这样的nginx配置,它运行良好,那么如何使用相同的tomcat端口配置子域?

server {
    listen          80;
    server_name     domain.com;
    root            /opt/tomcat/webapps;
    location /{
        server_tokens off;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:8080/;
    }
}

    server {
    listen          80;
    server_name     myapp.domain.com;
    root            /opt/tomcat/myapp;

    location /{
        proxy_pass http://localhost:8080/; //how to?
    }
}

感谢。

0 个答案:

没有答案