我有一個工作的春天mvc應用程序。我想讓測試版用戶可以看到它。我買了域名/設置名稱服務器和所有DNS的東西。Spring mvc tomcat應用程序部署
訪問我的應用程序低谷本地主機這樣的:
localhost:8080/myApp
但在現實世界我要訪問它像mydomain.com
。所以我搜索了很多,發現人們推薦nginx作爲「最快」的東西。因此,安裝nginx的與以下配置:
server {
listen 80;
server_name www.mydomain.com mydomain.com;
location/{
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://localhost:8080;
}
} #end server
問題:
當我訪問mydomain.com
我得到那個衆所周知的tomcat頁If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!
。
如果我手動去mydomain.com/myApp
那麼一切都按預期工作。
問:
有沒有辦法對我來說,配置該做到以下幾點:
當我在地址欄mydomain.com
我得到轉移到mydomain.com/myApp
或者I型在這種情況下完全關閉。有更簡單的方法來做到這一點?
更新:
每FVU建議,當我改變ROOT一些其他目錄,然後部署我的根目錄了,我從Tomcat得到404:
type Status report
message
description The requested resource is not available.
我可以檢索從這個錯誤服務器日誌:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [/tomcat_9090/webapps/myApp/] instead of [/tomcat_9090/webapps/ROOT
/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
更新II:
當我改變配置:
proxy_pass http://localhost:8080/myApp/;
該網站看起來像它的工作,但它確實沒有。鏈接不起作用,css/js不加載。
最簡單的就是將你的應用程序安裝爲Tomcat中的根應用程序,[如這裏所述](http://stackoverflow.com/questions/715506/tomcat-6-how-to-change-the-root-application ) – fvu
重新更新:請參閱http://stackoverflow.com/questions/5014651/webapproot-in-spring有關信息,解決方案和有用的指針wrt這個春天相關的問題 – fvu
也可能是你沒有取消部署應用程序,你最初加載(as/myApp)?我只會在任何時候都保留一份副本。 – fvu