Question

How to map domain name to Java application on TomCat server?

Hi there. I’m very new to server management, so sorry for maybe a stupid question. My droplet runs on CentOS 7. I’m using TomCat since my webapp is Java based. For now it is deployed and working under the standard URL http://my-droplet-ip:8080/myapp The thing is I can’t figure out how to make my app and my domain to be friends. :) I found some tutorials here like: https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars https://www.digitalocean.com/community/tutorials/how-to-set-up-a-host-name-with-digitalocean Also I found some info like this http://stackoverflow.com/questions/28647846/how-to-map-tomcat-7-webapp-to-my-domain They seems understandable each individually, but when I start to put them together it breaks apart. Did I get it right? There is a local file on the machine with the information about hosts. The tutorials from DO explains how to map the domain to a name server and also to update this local file via DO control panel. After that you can do some magic with TomCat server.xml since the “local file” (lets name it this way) now knows about the domain and the name server knows where to point the request to. This way, when the request comes to my droplet TomCat can see what app to give. Can you point where I’m wrong. Maybe give a hint or a link with a tutorial for my case? :) Thank you.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello,

In this case I would recommend using Nginx as a reverse proxy for your Java application. This would allow you to map your domain name and also you can secure it by installing an SSL certificate.

You can follow the steps on how to configure Nginx as a reverse proxy here:

https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-18-04-server

Regards, Bobby

This comment has been deleted

This comment has been deleted