Today i came across a situation where i had to do virtual hosting in windows with my application running in tomcat. After lots of try, i could come to a solution.
I had java application running in tomcat on port 8080. So the url was http://localhost:8080/myapplication. To host this application globally i needed to map this url to a global ip. Below are the steps how i achieved this:
1. Redirection of tomcat application is achievable using the Apache HTTP package. Firstly download the appropriate apache package from http://httpd.apache.org/download.cgi.
2. Install apache from the downloaded package. It will be installed in C:/Program Files/Apache Software Foundation/
3. Go to C:/Program Files/Apache Software Foundation/Apache 2.4(any version you downloaded)/conf folder. There you will find httpd.conf file
4. Open httpd.conf file with your editor and at the end of the file add the following code:
Note: 1. The VirtualHost tag may be commented with #, just uncomment it and add the above lines. If you dont find VirtualHost tag, simply copy the above code and paste it at the end of the httpd.conf file.
2. Here myApp refers to the application/project name. In all my posts i will be using myApp for application name.
Now my application runs on localhost instead of localhost:8080/myApp.
Thats all, You are done with virtual hosting.