今天在同一臺測試機器上搭建了IIS的站點,Tomcat的站點,weblogic站點。現在有個需求這三個站點都要使用80端口進行訪問,因爲是在局域網裏所以沒有辦法設置不同的域名作爲server_name。後面想到可以用二級目錄作爲區分。
所以修改nginx.conf文件添加:
upstream iis {
server 192.168.188.149:81;
}
upstream tomcat {
server 192.168.188.149:8080;
}
upstream weblogic {
server 192.168.188.149:7001;
}
server {
listen 80;
server_name 192.168.188.149;
charset utf-8;
location / {
proxy_pass http://192.168.188.149:81;
}
location /console {
proxy_pass http://192.168.188.149:7001/;
}
location /mytest {
proxy_pass http://192.168.188.149:8080;
}
}
訪問url就可以訪問到你的應用站點了。
訪問http://192.168.188.149/ 就是iis的應用,相當於訪問http://192.168.188.149:81
訪問http://192.168.188.149/console 就是訪問weblogic應用,相當於訪問http://192.168.188.149:7001/console
訪問http://192.168.188.149/mytest就是訪問tomcat應用,相當於訪問http://192.168.188.149:8080/mytest
這樣就實現了都通過80端口訪問應用站點