Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have Groovy on Grails app deployed on Tomcat/Apache (CentOS). Currently, it is accessed via a URL like http://www.domain.com:8080/AppName. I would like to access it via http://www.domain.com.

How do I go about this?

share|improve this question
add comment

6 Answers

up vote 3 down vote accepted

I assume that you are trying to move http://www.domain.com:8080/AppName to http://www.domain.com/ without the trailing AppName. In that case, you may want to consider running a reverse proxy in front of Tomcat. Merely switching the port from port 8080 to 80 would still require you to access your app via http://www.domain.com/AppName.

Apache can be configured to do this. You will just need to set up *mod_proxy* with the following config:

ProxyPass / http://localhost:8080/AppName/
ProxyPassReverse / http://localhost:8080/AppName/

You can also do this with other web-servers such as lighttpd or nginx and what nots, basically most reverse proxies can do it in one form or another.

share|improve this answer
    
Removing the trailing AppName without a proxy is as simple as naming the application ROOT. If Tomcat runs multiple applications each with their own domain, a Host can be configured for each of them (like an Apache VirtualHost) –  Bart van Heukelom Jul 7 '11 at 11:07
add comment

Setup your server to listen on port 80.

http://www.klawitter.de/tomcat80.html

share|improve this answer
add comment

I tried too solutions for that:

  • First one, i rund 2 tomcats servers behind a nginx web server as revers proxy, but i had problem with shared session, and i'm working on this solution.

  • Second one, that i kept is a kernel space port forwarding.

share|improve this answer
add comment

The default http port is 80, and unless you specify a port other than 80 in the URL your browser will attempt to connect to port 80. This is just the way that http works.

The solution is to reconfigure your web server to run on port 80 instead of port 8080. You'll need to check that there isn't already a site on port 80 first of course, and if there is your options are going to be limited.

share|improve this answer
add comment

The specification is that if there is no port number on a URI, then the default is port 80.

I had a Tomcat application that was running as port 80, and I was concerned as the Tomcat would run as root (due to port 80). Furthermore, I could not really be sure of the security of the application. So I decided to make the changes necessary to run this as another un-privd port. My problem as yours is keep the URI simple. I found on the web a few steps that I needed to do, and I was on a Linux sytem.

First, redirect port 80 to port 8080 (my designated alternative). You can easily do this by activating iptables, and using the following simple directives:

iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A OUTPUT -d your_hostname -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -d your_hostname -p tcp --dport 80 -j REDIRECT --to-ports 8080

I believe that I substituted my IP number for both localhost and your_hostname when I configured this.

Then, you need to make some changes in the Tomcat configuration file: (1) change the connector port to 8080 (for this example) and the proxy port to 80. You can then run tomcat as a non-root user, still have the simple URI, and everybody is happy. Sorry that I cannot remember the specific XML file to change here.

share|improve this answer
add comment

If your clients are accessing the site from outside of your subnet and going through a router/firewall type device you can configure that to forward the external port 80 to internal port 8080.

That way you can provide what looks like a normal app to external clients, and internally you can see reality.

This is also useful for something like:

app1.domain.com app2.domain.com

Forwarding to the same server internally on different ports.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.