Accessing Google Cloud VM Instance Tomcat using External IP - java

I am trying to access my Tomcat HomePage which is inside my Google Cloud VM Instance with External IP address 35.189.85.127 and Internal IP 10.154.0.2. On my local machine, in my browser I tried http://35.189.85.127 and http://35.189.85.127:8080 but got error
The connection has timed out. The server at 35.189.85.127 is taking too long to respond.
I have seen all the questions and replies on stackoverflow regarding this question but still I found no clear solution.
The steps that I've done so far:
I have setup a Google Cloud VM instance in Compute Engine. I am using Windows Server 2016 as the image.
Using RDP I log on to Windows Server.
I successfully installed Java 1.7 and Tomcat 7 on Windows Server.
I tested Java and Tomcat 7, both are working fine i.e. I open browser and type localhost:8080 and it shows Tomcat HomePage.
I replaced localhost with my VM Instance Internal IP i.e. 10.154.0.2:8080 and it again correctly shows Tomcat HomePage.
Now I try to access Tomcat HomePage using my VM Instance External IP (Static) 35.189.85.127 but in my browser I get error
The connection has timed out. The server at 35.189.85.127 is taking too long to respond.

Faced the same issue today.
Noticed from your question that you're using an Windows environment.
On Windows
Be sure that the Windows Firewall is properly configured to allow traffic under the ports you need (or deactivate it).
On GCP
Under "VPC Network/Firewall Rules", create a new firewall rule and configure as below:
Firewall Rule Parameters (image)
Or, you have the option to check the "Allow HTTP traffic" option under the Instance Configuration menu and edit Tomcat's server.xml to startup at port 80, as described here:
Change Tomcat Port Tutorial # StackOverflow

Option1: If it's just tomcat. GCP offers a click to launch Tomcat instance with an external IP. You can SSH and also have a temp tomcat username and password to manage any of your deployments.
https://console.cloud.google.com/launcher/details/click-to-deploy-images/tomcat
Option 2:
If you wish to have a Google Cloud VM instance in Compute Engine.
You will need to setup security groups and assign it to your instance.
Eg. Define rules to Open Tomcat port 8080(or any) externally / range. Assign that group/rule to your VM instance.
There are many options available, it all depends on how you wish to organize things. You could create a VPC and add your instances there or keep them under the same subnet or have them accessible externally etc.

Related

Set Up New Tomcat Server

I am kind of a newbie on server, environment stuff, so I need help on setting up a new Tomcat server.
Actually I have installed one instance and it is running already on my dedicated server, but I can't access it's main page, so it is made possible to deploy my apps.
These are the internet proccess in the server. Tomcat is running on port 8080. I tried to access it by IP:8080 and it doesn't work
So is there some extra configuration on a dedicated server to be made? Some security stuff?

Not able to connect localhost with system ip

I have deployed my java web application using apache tomcact in my system through Eclipse. I can access the same page with
https://localhost:8080/Home.jsp
as well
https://mysystemip:8080/Home.jsp
But the same page is not able to connect
https://mysystemip:8080/Home.jsp over the network through other systems. Previously it was working and now not. What issue causing this ?
Your Tomcat server is only bound to your local network interface. You need to bind it to all interfaces for it to be available.
There is already a solution (Can't access Tomcat using IP address):
Add address="0.0.0.0" to Connector string

Tomcat 7.0 issue

I have a tomcat7.0 running in a remote desktop machine say 204.34.34.45.
When I log into the remote desktop and try "http://localhost:8080" it is working fine.However
http://204.34.34.45:8080 is not working.
I am able to ping 204.34.34.45 from outside the remote desktop machine.
Do you know how can I access tomcat outside the remote desktop machine.
The firewall rules for that host may not allow connections to 8080. Talk to your system administrator for details.
Also, make sure you have the correct IP bindings set up for tomcat. It is possible to allow connections to localhost:8080, but disallow them from 204.34.34.45:8080. See How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses?

How to configure Apache to redirect subdomains to Tomcat applications

I have a few applications hosted on Tomcat running a machine called test-websites throuhg port 8080. So they are accessible like this:
http://test-websites:8080/app1/
http://test-websites:8080/app2/
...
http://test-websites:8080/appN/
What I need to do is make these applications accessible on my local network by:
http://app1.test-websites/
http://app2.test-websites/
...
http://appN.test-websites/
As I add new applications to Tomcat's webapps folder, I want them to be automatically available using the same subdomain pattern.
So I thought using Apache in front of Tomcat to make the URL rewriting would be a good idea, but so far I have not been able to configure the virtual host on Apache to make this redirect. I installed apache2 on port 80 and I see the default "It Works!" apache page when I access http://test-websites/, but I couldn't find how to make the redirects to the apps in the Tomcat following the format above.
I have searched for over 4 hours and didn't get an answer for this use case.. any help us much appreciated!
Thank you!
Eduardo
First you need to add a DNS entry for app1.test-websites, app2.test-websites,.. such that it points to test-websites. Generally CNAME entry works best in this case. If you only need the URLs to resolve on your local machine (for testing purpose), you can just update your /etc/hosts or C:\windows\system32\drivers\etc\hosts file. Otherwise you need to figure out how your company's network is setup and change the DNS entry (if it's a Windows domain network, normally there's a DNS service on the domain controller. On some smaller network you have to configure it on the router).
Next, the quickest way to achieve this is to not use apache2 to front it, bust simply have tomcat listening on port 80. You can setup virtual host on tomcat such that it serves different web-app depending on the URL requested.

How to connect to machine ip address & port via grails app

I'm running MacOS 10.6 with the default settings for my machine with Internet Sharing turned on.
What needs to be configured to allow access to my machine's grails/jetty instance on a specific port?
I can do 'http://localhost/' as well as 'http://192.x.x.x/' but if I were to set my grails app to run on a specific port, I can't access it with: 'http://192.x.x.x:8081/'.
The browser can't establish a connection with this address from my own machine and I know that I need to establish an accessible port in some config file.
I used to be able to do this prior to an upgrade from the last version of the OS but it's been so long I don't remember what I did the last time.
NOTE: I can use 'grails run-app -Dserver.port=' to specify a port number for jetty to run my grails application but that still doesn't allow my machine to be accessible by ip address & port number.
grails run-app -Dserver.port=<port number>
run-app Runs a grails app using the default Jetty container. The default http port is 8080. This can be customised by appending -Dserver.port= to the command line
See the grails website for more details.

Categories