tags:

views:

405

answers:

3

I don't know how to access my deployed war file like this www.mydomain.com

Instead I have to access it i.e http://mydomain.com:8080/WarFileName

I would like to fix that and also be able to deploy/host more than one domain on the same Tomcat server i.e. www.mydomain1.com and www.mydomain2.com on the same tomcat server without the port 8080 variable in the url

Is Server.xml is the missing piece of the puzzle?

Info: linux box, tomcat6, staticIP

A: 

You need to set up virtual hosting on Tomcat. It's done by adding a separate <Host> entry for each domain under the <Engine> element in server.xml. More details in the link I provided above.

Asaph
Been there, but I don't see how this will solve the 8080 issue!?
tranced_UT3
@GrailsNewbie: Open up server.xml and search for "8080" and replace it with "80" (in 2 places, I think). Then restart tomcat as root (because non-root users cannot bind to port 80) and you won't need the 8080 in the url
Asaph
@GrailsNewbie: If my above instructions for switching the tomcat port from 8080 to 80 don't work, it could be because another web server is already running on port 80 (usually apache). If that is the case, just stop apache before starting tomcat.
Asaph
A: 

First off, you need to make sure that you have you have the proper DNS settings, i.e. that www.mydomain.com and mydomain.com both point to the same IP address (this is handled through whoever your DNS provider is). Changing this is outside the scope of stack overflow and can be asked on Server Fault if you need more details.

While you can modify the tomcat instance to change the port from 8080 to 80 it provides on and move your application location from /WarFileName to /, this is not usually how Tomcat is deployed. Usually Tomcat is left on its default port and an apache proxy is placed in front of it to redirect requests from a public domain like http://www.mydomain.com/ to the internal Tomcat instance at http://localhost:8080/WarFileName.

Jherico
the proxy thing sounds neat to me... how to do that?
tranced_UT3
Jherico
Honestly, its not really a subject that can fit into a SO post and its not really a subject for Stack Overflow anyway. Try asking on Server Fault which is more appropriate for asking server configuration type questions.
Jherico
@Jherico: Why should the OP bother with the apache proxy? What would be the benefit here? I see no reason for the added complexity in the OP's setup.
Asaph
@Asaph: yes you are right!"Configuring Tomcat so that all of its requests must first travel through Apache httpd may actually slow down Tomcat’s response times, and it is usually the performance of the dynamic content that web server administrators need to improve."Reference: Tomcat, The Definitive Guide, Second Edition, O'Reilly 2008So to get it done without the apache proxy, just change the 8080 to 80 in the server.xml? I tried it and it doesn't work for me!?
tranced_UT3
@GrailsNewbie: Please post your `server.xml` so we can look at it.
Asaph
A: 

You need to make following changes,

  1. Change your war name to ROOT.war so you can access it without "/WarFileName".
  2. Change port number in the HTTP connector from 8080 to 80 in server.xml. On most OSes, you have to run server in privileged account (root in Unix) to use port <= 1024.
ZZ Coder