以下是先决条件:
example.com在高爸爸。8080端口上使用几个应用程序运行Tomcat。8080港口向世界隐藏。subdomain.example.com映射到server:8080/subdomain。我希望将来能够进行类似的映射(例如,subdomain2.example.com到server:8080/anotherContext )。example.com应该映射到server:8080/mainPageAppexample.com/app -> server:8080/app。目前,我只配置了good(我不知道这是否好):

你能帮我解决这个案子的nginx配置吗?这是我的,但它发送无限重定向:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
}
server {
listen 80;
server_name subdomain.localhost;
location / {
proxy_pass http://127.0.0.1:8080/subdomain;
}
}发布于 2013-03-23 00:49:13
好的。我有这份工作。不确定解决方案是否正确,但:
首先,我需要在Tomcat中设置一个子域。Here is the answer I was inspired with.
<Host name="subdomain.example.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="subdomain" />
</Host>然后,用以下方法配置nginx:
server {
listen 80;
server_name example.com;
location / {
root /path/to/domain/root;
index index.html;
}
}
server {
listen 80;
server_name subdomain.example.com;
location / {
proxy_pass http://subdomain.example.com:8080;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}域配置仍然和问题一样--它很好。
最后,我将subdomain.war放到Tomcat的webapp目录中,它工作起来就像一种魅力!
https://stackoverflow.com/questions/15543350
复制相似问题