-3

I am currently working on my own web application. I am hosting aws linux server. My question is:

I can deploy war file into /var/lib/webapps/test.war, and access each single page from this war, furthermore, I am binging A record to my ip address. Assume, I am binding www.test.com to my ip. So that I can access my web page from test.war by www.test.com:8080/test/single.html.

How can I access only by www.test.com/single.html?

One more thing is, if i have one file t.html under /var/www/html/t.html. I can access this file by www.test.com/t.html.

How should I deploy my test.war in order to access it by www.test.com/single.html

Let me know if any description is not clear. I tried couple of days. Hope anyone can help!

Huazhe Yin
  • 355
  • 1
  • 4
  • 19

3 Answers3

1

Do you need to deliver static content via the Apache HTTP?

  • YES: Configure Apache as reverse Proxy for Tomcat.
  • NO: Configure Tomcat to listen on Port 80.

EDIT: Since i realized you need further explanation:

  • Apache HTTP normally listens on Port 80. A Web-Browser tries to connect on Port 80 or 443 automatically when u enter a domain or an IP. Apache HTTP usually serves content from /var/www/....
  • Tomcat is an Application Server and listens in your case on Port 8080. Tomcat deploys webapps from /var/lib/webapps (With your configuration).
  • You cant just put a Java webapp in Apache's Document root. Apache has no Idea how to handle such content...
  • If you want to reach your webapp on Port 80 you can either reconfigure Tomcat to listen on Port 80 or use the Apache HTTP as reverse proxy (https://en.wikipedia.org/wiki/Reverse_proxy).
  • READ THE DOCS!
Thomas Maier
  • 346
  • 1
  • 10
  • my application is dynamic web app. i am curious about that if i access my website only by ip. it will show me the page. Here is my ip. [link](http://52.87.200.175). this welcome page is under /var/www/html. However, if i access my website by ip and port number. [link](http://52.87.200.175:8080). this welcome page is under /var/lib/webapps my goal is to deploy a war of app into /var/www/html. what should i configure? – Huazhe Yin Sep 13 '16 at 17:50
1
  1. Change the port of Tomcat from 8080 to 80. Currently, your tomcat server listens to port 8080. Only if it listens to port 80, the suffix :8080 will be hidden. Only one application can bind to a port at a time, so make sure your Apache HTTP server is not binding to 80.

  2. Change the port of Apache HTTP or just stop this service.

  3. Back up files in folder webapps/ROOT, because your following action will replace its content. Rename test.war to ROOT.war and deploy your application at the root in Tomcat.

Community
  • 1
  • 1
Mincong Huang
  • 5,284
  • 8
  • 39
  • 62
0

Rename test.war to ROOT.war (capitalization important) and deploy it to the same location. Tomcat will use that as the "root" webapp and you won't need to include a folder in the URL.

Mark Olsson
  • 320
  • 2
  • 8
  • so you mean I just simply rename test.war to ROOT.war? and deploy it into /var/www/html ? I just tried it, and it still does not work. The Tomcat will only auto deploy the app under /var/lib/webapps. Any leads? And thanks for the comment. – Huazhe Yin Sep 14 '16 at 01:35
  • Copy ROOT.war to the webapps folder. As long Tomcat is configured to auto deploy, it should expand it and work. Or you could use the Tomcat's manager to deploy it too, that will make sure it goes to the right place. – Mark Olsson Sep 14 '16 at 01:47