1. 程式人生 > >nginx tomcat 配置 多個 二級域名 多個專案

nginx tomcat 配置 多個 二級域名 多個專案

我想要的是 訪問 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 指向專案名稱。 在此與大家分享下。再次感謝各位的回答、^_^

  1. server
  2. {
  3.     listen 80;
  4.     server_name news.test.com;//前臺訪問地址
  5.     root {WEB_ROOT_PATH}/news;
  6.     access_log {LOG_ROOT_PATH}/news.log;
  7.     location /{
  8.         proxy_pass http://news; //tomcat後臺處理地址
  9. }
  10. }
  11. server
  12. {
  13.     listen 80;
  14.     server_name forum.test.com;//前臺訪問地址
  15.     root {WEB_ROOT_PATH}/forum;
  16.     access_log
    {LOG_ROOT_PATH}/forum.log;
  17.     location /{
  18.         proxy_pass http://forum; //tomcat後臺處理地址
  19. }
  20. }