我已经在apache / tomcat中部署了两个应用程序,它们正在按以下方式运行(http://xx.xx.xx.xx:8080/castag/,http://xx.xx.xx.xx:8080/filltag/),并且可以正常访问
但我的要求是
http://xx.xx.xx.xx:8080/castag/ ------> casstag.abc.com
http://xx.xx.xx.xx:8080/filltag/ -----> filltag.abc.com
为此,
1。在dns服务器中添加两个主机A记录
2。我已经安装了nginx服务器,并在apache tomcat服务器中的server.xml中进行了一些更改
<Context path="/casstag" docBase="/opt/apache-tomcat-6.0.45/webapps/casstag" debug="0"
reloadable="true" cachingAllowed="false"
allowLinking="true" />
<Context path="/filltag" docBase="/opt/apache-tomcat-6.0.45/webapps/filltag" debug="0"
reloadable="true" cachingAllowed="false"
allowLinking="true" />
server {
listen xx.xx.xx.xx:80;
server_name def.abc.com ;
root /opt/apache-tomcat-6.0.45/webapps;
location / {
deny all;
}
location /castag/ {
index index.jsp;
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://xx.xx.xx.xx:8080/castag/;
proxy_redirect http://xx.xx.xx.xx:8080/castag/ http://casstag.abc.com ;
proxy_buffering off;
proxy_store off;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 120;
}
}
server {
listen xx.xx.xx.xx:80;
server_name def.abc.com ;
root /opt/apache-tomcat-6.0.45/webapps;
location / {
deny all;
}
location /filltag/ {
index index.jsp;
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://xx.xx.xx.xx:8080/filltag/;
proxy_redirect http://xx.xx.xx.xx:8080/filltag/ filltag.abc.com ;
proxy_buffering off;
proxy_store off;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 120;
}
}