I've got a working spring mvc app. I want to make it available for beta users to see. I've bought domain name/setup nameservers and all that dns stuff.
I access my app trough local host like this :
localhost:8080/myApp
But in the realworld I want to access it like mydomain.com
. So I googled a lot, and found people recommend nginx for these things as "the fastest". So installed nginx with following configuration :
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
The problem :
When I visit mydomain.com
I get that well known tomcat page If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!
.
If I manually go to mydomain.com/myApp
then everything works as expected.
Question :
Is there a way for me to configure this to do the following :
When I type in the address bar mydomain.com
that I get transfered to mydomain.com/myApp
Or I'm completely off in this case. There is easier way to do this?
update:
Per fvu suggestion when I change ROOT to some other directory then deploy my up in the ROOT directory I get 404 from tomcat :
type Status report
message
description The requested resource is not available.
I can retrieve this error from the server log :
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!
Update II :
When I change configuration to :
proxy_pass http://localhost:8080/myApp/;
The website looks like it's working, but it really doesn't. Links don't work, css/js doesn't load.