nginx tomcat 配置 多個 二級域名 多個專案
阿新 • • 發佈:2018-12-25
我想要的是 訪問 news.test.com , 實際訪問的是 tomcat 下面的news 專案 ,訪問 forum.test.com ,實際訪問的是 tomcat 下面的 luntan 專案,但是瀏覽器地址 欄url news.test.com 、forum.test.com 不變 ,不要變成 news.test.com/news 或者 forum.test.com/luntan 這樣的,如何配置? 請教
謝謝各位的回答,已經解決了。 需要在tomcat裡面配置虛擬host。 Host名稱為需要訪問的域名。
path="" docBase="/opt/tomcat/webapps/news" . 如果訪問首頁域名後面不加訪問路徑的話。path需要為“”。 docBase 指向專案名稱。 在此與大家分享下。再次感謝各位的回答、^_^
- server
- {
- listen 80;
- server_name news.test.com;//前臺訪問地址
- root {WEB_ROOT_PATH}/news;
- access_log {LOG_ROOT_PATH}/news.log;
- location /{
- proxy_pass http://news; //tomcat後臺處理地址
- }
- }
- server
- {
- listen 80;
- server_name forum.test.com;//前臺訪問地址
- root {WEB_ROOT_PATH}/forum;
- access_log
{LOG_ROOT_PATH}/forum.log;- location /{
- proxy_pass http://forum; //tomcat後臺處理地址
- }
- }