Tomcat Problem for external access?
I don't know how to access my deployed war file like this www.mydomain.com
开发者_JAVA百科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
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.
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.
You need to make following changes,
- Change your war name to ROOT.war so you can access it without "/WarFileName".
- 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.
精彩评论