It's not a secret anymore!
The moose likes Tomcat and the fly likes tomcat and httpd couplage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat and httpd couplage" Watch "tomcat and httpd couplage" New topic

tomcat and httpd couplage

djanahanaa djanahana

Joined: Nov 27, 2013
Posts: 1
Hi every one,

i have an application in our university the application is in the URL

i want to delete the port number 8080 form the URL and also the /jspui of the application

thanks in advance
Joe Areeda
Ranch Hand

Joined: Apr 15, 2011
Posts: 331

Hi Djanahanaa,

The way we do it is with what's known as a "reverse proxy"

The Apache configuration looks like:

We also removed the Tomcat listener on port 8080 because much our security uses Shibboleth via Apache so we don't want people connecting directly to Tomcat, but that may be optional in your case.

I suggest enough reading of Apache documentation to understand what the ProxyPass directive does, as well as setting up a VirtualHost. Apache configuration is ..let's just say.. less than obvious and copying snippets like that can get you into more trouble than it solves.

It's not what your program can do, it's what your users do with the program.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Actually, that's a forward proxy. Reverse proxies go the other way, but must be handled with care because Bad People will abuse them to send spam through them. There are 3 places in China that continually hammer my servers trying to do just that.

All TCP/IP URLs have certain default assumptions. If the URL protocol is "http:", it's that the client will send the request to the server's port 80 (that's what tomcat's ":8080" suffix is for - to override that default). For "https:" it's 443. You cannot change this. It's hard-coded into the clients. DNS only knows server addresses, not port IDs.

There are actually 2 ways to get rid of the ":8080" in the URL. One is to remap Tomcat to listen on port 80 instead of 8080. Not generally recommended, since it requires running Tomcat with root privileges, making it a security risk. The other way is to use a proxy, as Joe said. Apache's mod_proxy can do this, as can the older mod_jk.

Likewise, there are 2 ways to get rid of the application context path from a URL. One is to deploy the app at Tomcat's root in place of the original root context webapp that comes with Tomcat. I don't really favor this, since it deprives you of that webapp and it's not symmetrical when you have multiple apps in the same Tomcat Host, which can be confusing. But a lot of people do prefer it.

The other way to get rid of the application context path is to have your proxy server rewrite the URL. This can be done via Apache mod_rewrite, although you can also specify the context in the actual ProxyPass declaration.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: tomcat and httpd couplage
It's not a secret anymore!