0

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?

6 Answers 6

4

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.

2
  • 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) Jul 7, 2011 at 11:07
  • how to setup mod proxy? is this is available for apache2?
    – PeakGen
    Jul 24, 2015 at 8:28
5

Setup your server to listen on port 80.

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

1

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.

0

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.

0

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .