Well, to change the port that Tomcat uses is a simple matter of changing the entry in the server.xml file under conf directory. For Tomcat 4.0.X the entry looks like
And in Tomcat 3.2.X
In both cases change the port to 80 and you remove the requirement to provide a port on the url string. This should also eliminate the need for http:// but, that's a function of the browser. Most browsers use the default port of 80 and that the protocol is http. When you specify a port, it needs to know what protocol you want to use so, requires that you add http://. Note, this is if you are only using Tomcat as the webserver. If it's used in conjunction with Apache, IIS or any other server, the process is completely different.
why are you accessing it with a port number at all?
Tomcat can be configured to respond to HTTP requests on port 80. That much you have probably done already. That HTTP connector has a configuration parameter named 'redirectPort' which is 8443. This is the port it will redirect SSL traffic to.
So something needs to be responding on 8443, which is why you need to uncomment the SSL connector, make sure *its* port is 8443, and also follow the other directions in the 'howto' comment in server.xml. Which you've also probably already done, since you seem able to get localhost:8443 to work.
I'm just posting this to confirm that you've done these things, because you "ought" to be able to remove the port number with these settings.
It will only redirect to https if you have a matching <security-restraint> element (in web.xml?)
Joined: Jul 29, 2004
thanks for the reply mike!
i've tried naming all the redirectPorts in server.xml to 443 instead of the 8443 default. i have learned that 443 is considered as a "universal" secured port so when you access the site, the browser does not anymore display the port number.
its good, though our company has another concern: since 443 is known as "universal" it can be the target of all hacks. we need to name a port other than 443 that we may consider "secure" but wont appear to the address bar, so any hacker wont have a clear target to hack.
im open with some ideas using jsp's too. any help will do. thanks!
The reason that your browser switches to '443' for SSL, without you having to type :443 at the end of the URL, is precisely because it is "universally known".
Being worried that this leaves you open to attack, is like being worried that port 80 is "universally known" to be the http port, and so you should try to somehow run on port 85, while magically having browsers read the minds of your managers, and know to try 85, instead of that other 'well known and therefore unsecure' port.
So... you can get this to work on 443? (with no port showing on the address bar?) If so, this is what you really do want. Cajole your managers.
When you don't specify a port in a URL, browsers will use the default port - 80. There are a few ways to get your Tomcat to work for port 80:
1) Change the Tomcat configuration to use port 80 instead of port 8080.
2) Use Apache HTTPD (or IIS) in combination with mod_jk. The response comes into Apache HTTPD which then uses the mod_jk module to communicate with Tomcat's port 8009. Through this port the responses are sent back to Apache HTTPD which then sends the response back to the browser.
There are quite good instructions on the second solution on Apache Tomcat's own website.
You've already tried to use the first solution. However, that would mean that your web server should not respond for port 8080. That leaves two possibilities:
1) You didn't restart Tomcat after making these changes.
2) You have two connectors, one for port 8080 and one for port 80, and the first one is blocking the second one from being active.
There are only three big differences between your server.xml and mine:
1) I have an explicit Executor. You don't need that though.
2) I have "localhost" as the Host name.
3) I have "webapps" as the appBase.
The latter is the one I think is the oddest. The appBase should be the base directory of all web applications. Yours seems to be the base directory of only one web application. Perhaps this is causing the problems.
Hi, I don't use windows but after googling a bit, it seems windows doesn't require the authbind solution sorry.
Joined: Apr 19, 2007
Hi Rob Spoor,
Thanks for your quick response. I am new to Tomcat server. If i change appBase to webapps, then how to configure my apps to this URL. Because i have more than one application under webapps directory. Or if i have only one application under webapps,will it work?
DSN record? Do you perhaps mean DNS? If so, then you could try by pinging the domain name and see what IP address shows up.
If Tomcat's still working on port 8080, you've specified that Tomcat should run on port 80, and you've restarted Tomcat, that could mean that you are perhaps connecting to some other Tomcat instance, or perhaps another connector inside the existing Tomcat. Do you have two connectors?
Tomcat itself should be able to run on port 80. I just don't know why it doesn't work. mod_jk (rather than mod_proxy) can be used, but it adds another layer that should not be necessary. mod_jk should only be used to incorporate JSP files and servlets in an already existing Apache installation, or to load balance two or more Tomcat instances.