Tomcat 7 Virtual Host Added, Application Link Not Working - tomcat7

Using Apache Tomcat 7 as a windows service, with an AJP13 connector to connect Tomcat 7 to IIS.
I know how to update sites that are already hosted on this set up, but I've been trying to deploy a new application. Added the Host tag in server.xml
<Host name="mySite.com" appBase="mySite.com"
unpackWARs="true" autoDeploy="true"/>
Created a folder under Tomcat labeled mySite.com.
Dropped in the war file in the webapps Tomcat folder. It unpacked and deployed to the Tomcat manager site perfectly. When you visit Tomcat 7 manager app and click on the deployed link for the site, it loads the web application.
Then I copied the 3 folders from webapps\mySite.com to Tomcat\mySite.com\ROOT. Then went to the host manager and added the virtual host. The mySite.com link appears there in the list of virtual hosts, but when I click on it I get a 404 error- "The web page cannot be found"
When you try to access the site from an outside connection, you get "The page cannot be found" and "No web page was found for the web address."
Did I miss a step setting up my virtual host?
Did I add the virtual host App base incorrectly? currently it is set as C:\Tomcat\mySite.com.
Any ideas how to fix the error I am seeing? My log files don't say anything so I'm just not sure what is happening...
Also, all the tomcat docs say something about a Context file, but there is only one in Tomcat\conf folder that should be working for all sites hosted on this instance of Tomcat.
Also, all the other sites hosted on this Tomcat instance have one service and one connector port listed in the server.xml folder. So it's not a matter of adding another service. Adding another Host tag should have worked.
Any ideas on what I am missing or why this isnt working?
Would appreciate any help or ideas! Thank you!

Related

App runs on local Tomcat instance, but gives 404 on virtual server with identical software and setup

I have a Vaadin and Spring Boot app that runs in the Tomcat instance on a local server.
Whenever I deploy it to the Tomcat instance on a virtual server hosted by a provider, I get a 404 and the application log isn't created. There are no errors in any Tomcat logs and Tomcat manager shows the app as running.
I've deployed another Vaadin / Spring Boot app to that same Tomcat instance that's just a static html page and it both runs and creates an application log. I've ran the app on an old mac with the same amount of memory as the virtual server just to rule out a memory issue.
Both my local server and the virtual server are running Debian with the same versions of Java and Tomcat. The only software difference I'm aware of is my local server is Debian 10 and the virtual server is Debian 9. No other software has been installed except UFW which is disabled.
The virtual server has no other firewalls. I tried adding a static html page to the project root, and that gives a 404 too.
I assume any careless errors in coding and configuration are automatically ruled out by the fact that it runs on a local server. How do I debug this?

How can I access a webpage located inside a VM from the host machine's browser?

I am able to access the link http://localhost/men/tops-men/jackets-men.html successfully from my VM (configured using X2Go client).
IP Address of the VM: 10.146.106.204
I am also able to ping the VM successfully from my host machine (Windows).
The page that I am trying to access is a php page deployed on Apache Web Server.
However I am not able to do so from my Windows host machine.
I tried http://10.146.106.204/men/tops-men/jackets-men.html from my Windows machine but it did not work.
Do I have to configure something on my host machine or on my VM ?
Not sure what I am missing.
On VM check you can view http://10.146.106.204/men/tops-men/jackets-men.html
If not you need to configure the web server to listen on that IP (if you're running IIS this is under "bindings" in the right-hand side panel of IIS Manager).
On Host open a cmd window and check you can ping 10.146.106.204
If not check your firewall settings on the VM.
If neither of these 2 things help then you need to add more information about your setup to the question. Those are 2 very simple things you can do to diagnose 2 basic problems you might be having.
I was finally able to solve the problem based on this SO link: Unable to access magento site from anywhere but localhost
Updated the DB table core_config_data and updated the data by replacing http://localhost with http://ip-of-vm and then restarted the apache web server.

Redirect tomcat to maintenance page when my tomcat is down

I just joined a new company and it was told that the sites they have uses tomcat. And, they want to show a custom web page when tomcat is down. currently it will show Error 500. I am the only person in IT team for now and I am pretty new to tomcat and do not have knowledge about tomcat.
Can someone please explain how to setup a custom web page when tomcat is down?I am using only tomcat not apache or load balancer infront of tomcat.
Thanks in advance.
You have to use apache 2 or load balncer in front of tomat.And configure a maintenance page in apache or load balancer.
If you have any problem just post it
This answer may not the correct way but hope it will help to the folks who do not want to use (or not allowed as in my case) apache 2 or load balancer in front of Tomcat server. This solution is for Tomcat servers that contains only one application instance.
I also had a similar problem and they expected a solution without having apache 2 or load balancer in front of tomcat (because it’s a live project and they do not want to change the architecture).
I used two instances of Tomcat server to come up with a solution. The OS is windows and Tomcat server configured as a windows service.
I copied the Tomcat server and create another windows service for this new server. Then I created a dummy project (war file name is same as the original project name) with maintenance html file and deployed it in the new Tomcat server.
Finally created two batch files, one for stop the main Tomcat server and start the maintenance Tomcat server and other one to reverse this process. So once you execute the batch file it will stop the main Tomcat server and bring up the maintenance Tomcat server.
Below is a sample can use in batch file.
#echo off
echo Main Tomcat server will stop
NET STOP "Tomcat9"
echo Maintenance Tomcat server will Start
NET START "Tomcat9-MAINTENANCE"
PS: We can use these batch files in Windows Task schedulers also.

setup tomcat personal webserver

i hosted an apache server by changing few details in the httpd.conf file, used this tutorial. i also did port forwarding so that the server is able to respond behind the wireless router (firewall), it worked completely fine ( i checked by typing the ip and port number from some other host outside the network). now i am trying to run servlets for which i need tomcat server. i have installed tomcat but i am unable to access the server from another host that is not on the same network. could somebody please guide as to how can i achieve this.
I guess I would go with The Apache-Tomcat Connector and use it to connect your new tomcat instance to your Apache.
I did the same thing just as I for apache server, except that I changed the listening port to something else. added that entry in the router. incorporated tomcat in eclipse and then started the sample project. using whatismyip.com, i got the ip address. i could access my webserver from elsewhere...

Accessing TEAMCITY from a remote machine

I am having trouble browsing to my team city(JetBrains) from a remote machine. I have followed the install directions and the install went smoothly. I can browse the to application locally on the server, no problem at all. I changed the default server url in the config file to be http://my servername . I can browse to http://my server name and the application shows up no problem locally. The application is alos installed on the default 80 port of the server with no other web server installed.
If I browse to http://my servername from my laptop on the same domian nothing happens. When I run diagnostics it seems to pick up the webserve but it fails to respond.
As a test I uninstalled the app and installed IIS to see if I could browse to the default IIS page remotely. This worked no problems at all. I uninstalled IIS, ensured nothing was hogging port 80 on the server. Reinstalled the applicaiton, configured it exactly the same, still nothing. The application works fine locally, but I get nothing remotely.
I was just wondering if anybody knows anything else I can try? or is there a setting in tomcat I need to tweak?
I just updated TeamCity from 7.0 to 7.1, and now I have the exact same issue.
However, what turned out to be the cause had nothing to do w/ the TeamCity upgrade. It turns out our system administrators had setup a policy update to block all incoming connections other than port 80. When I started my upgrade, I noticed the server wanted to do some system updates. So I let that go first.
I suspect that had I tried to access the TeamCity server after the system update, I'd have realized I could no longer access the website remotely.
But since I only noticed it after the TeamCity update, I assumed it to be the culprit and wasted a bunch of time on that red herring.
The solution for me was to
Open Windows Firewall on the server
Click on the root level option in the left-hand pane
Make sure under each of the profile sections, that inbound connections are allowed.
(#3) was my problem.
Hope this helps someone else out in the future...
Verify that the server is running on port which is not blocked by the firewall. Change the port if necessary.
Tomcat also supports binding to specific IP addresses, in case your machine has multiple IPs, you can configure which one to use in server.xml, like:
<Connector port="80" address="10.10.10.10" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Where 10.10.10.10 is the IP of the server which can be accessed from the remote machine.
Check the server logs to ensure that it's started on the correct IP/port and is accepting connections.
I just faced the same issue when evaluating TeamCity v10.0.
I solved it by changing the 'Server URL' value with the name of my computer that can be used from remote computer.
As they say, "make sure the server is accessible by the URL specified".
To reach this setting:
- Login to TeamCity interface then
- Click on the 'Administration' link
This is well explained in the TeamCity support page:
https://confluence.jetbrains.com/display/TCD10/Configuring+Server+URL
The problem is that TeamCity's default server.xml has localhost as the host name. You need to add an alias for it answer that name as well, as described here:
http://tomcat.apache.org/tomcat-4.0-doc/config/host.html#Host%20Name%20Aliases
Ryan

Resources