1

I've got a tomcat server instance running inside of eclipse. By default it uses a hostname similar to http://localhost:8080/MyApp/ is there some way to proxy this so I can use a domain name like http://example.com/ instead?

On the production server I use apache to proxy the request to point to the tomcat instance, but within eclipse I don't have that luxury.

I'm using Ubuntu. I thought maybe I could map the domain to point to the localhost version in /etc/hosts but that seems to only be the first step. From there I can't figure out how to point the domain to the tomcat url.

ryandlf
  • 27,155
  • 37
  • 106
  • 162
  • That means I would have to use example.com:8080/MyApp/. I'd like to setup my dev machine so I can access a locally running instance of tomcat by using just the domain just like I would on the production server. Normally I would use apache to proxy and redirect the url, but here i'm using tomcat within eclipse so i'm limited. – ryandlf Jul 29 '15 at 03:21
  • If I have to use MyApp after the domain there really isn't much point in changing it. The reason I want to use the actual domain on the testing server is so I can map urls a little cleaner without having to specify the application name only when dev mode etc. – ryandlf Jul 29 '15 at 03:32

1 Answers1

1

Add this to your hosts file, to access via domain name : localhost example.com

Now, You have couple of options :

  1. Host file doesn't know about ports. You have to access your app like http://example.com:8080/MyApp

  2. You can change your tomcat port 8080 to 80 so that you dont have to access it via port like this http://example.com/MyApp

  3. To access your web application via http://example.com, you have to deploy your application in tomcat root. For that refer Deploying my application at the root in Tomcat

Community
  • 1
  • 1
Darshan Patel
  • 2,839
  • 2
  • 25
  • 38
  • Although I was initially looking for an alternative method (running tomcat on port 80 conflicts with apache etc) I guess this is the only way for now. – ryandlf Jul 31 '15 at 02:10