I have developped a web application with Tomcat 8.0. The Tomcat is installed as a windows service in windows server 8.0. So, I run the app (inside my network) from the url http://192.168.1.2:8080/MyWebapp
. Is there any way replace this, with a domain name like www.mywebapp.com
which will navigate to my web app?
I tried in my pc (windows 8) edit the hosts file in System32
folder by adding this line http://192.168.1.2:8080/MyWebapp
www.myapp.com but with no result.
You misunderstand how DNS works, and so you have broken your hosts
file.
DNS doesn't care about protocols, only about IP addresses. Do it like this:
192.168.1.2 www.myapp.com
IIRC, Windows requires a reboot after modifying the hosts file for some reason. If it doesn't work right away, reboot.
Remember that hard-coding the hostname of the web application in your application is a mistake: you'll have to re-write the app just to move it to another server. Instead, make all of your links relative to the current host, and to the current context path (whatever it may be: also don't hard-code that, in case you want to re-name the application in the future).