本人新手,胡亂搞的,噴能夠,可是輕一點,我怕痛。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>額,大概就是這麼個意思...