Reputation: 347
I installed a MEAN stack on Google Cloud Engine (GCE) via this link.
So the engine created my instance successfully and it looks like this:
I created a new firewall rule to accept any incoming requests (actually do I need to do this? default-allow-http has the same rule right?):
But when I try to access the IP using Chrome, I get an error. The error persists even when I change the browser e.g. IE or Firefox:
I have confirmed that I can ping the address:
I even tried to assign a domain name to the instance but it still does not work:
May I know what I am doing wrongly?
Would appreciate any advice! Thanks in advance!
Upvotes: 14
Views: 15634
Reputation: 1
To access Google VM Instances through http follow below steps:
NOTE: Edit the port no. as per you requirements
Upvotes: 0
Reputation: 22867
I had the same problem after installing the JIRA Core app, and I was able to solve it with the following steps. I honestly did not install MEAN stack but most of the steps to solve this error must be the same (except for port verification and service execution).
The first thing is to detect the port used by MEAN stack app in the official documentation and in some configuration file generated by the installation of the app. According to information in the comments the app uses the port 3000
You go to the GCP console to add a VPC Network firewall rule.
a. You choose the project where you have the instance.
b. Select VPC Network -> Firewall Rules -> Create
c. Name: mean-stack
d. Intervals of IPs: 0.0.0.0/0
e. Protocols/ports: tcp:3000; udp:3000
List the ports that the VM is listening to or the firewall enables from the Cloud Shell:
$ netstat -an | grep "LISTEN "
You have to open the port for MEAN stack that blocks the firewall. If the port is listening, this step is not necessary:
$ sudo apt-get install ufw
$ sudo ufw enable
$ sudo ufw allow ssh
//so as not to be disconnected from the instance by ssh
$ sudo ufw allow 3000
If the app uses more control ports, you must also enable them
You should check that the app is on and running with some command (For example: sudo /opt/bitnami/ctlscript.sh start apache)
You should test if you can access the MEAN stack app locally through the URL. The following command does NOT have to give me connection refused.
$ sudo wget http://localhost:3000
Do not enter the URL generated by wget, as it must be done with an external ip.
Finally, after creating a firewall rule for the project of the instance and enabling the port that blocks the firewall you can access from any client through the browser.
http://< external-ip-vm >:< port >
I hope I can help you at some point. GL
Upvotes: 5
Reputation: 69
MEAN stack app is running with Express on port 3000 (default address) only on localhost address for security reason. To promote application to be visible on internet (on port 80), just create a proxy reverse clause on apache (or nginx, or...).
sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
add this statement like this : ProxyPass http://localhost:3000 ProxyPassReverse http://localhost:3000
sudo /opt/bitnami/ctlscript.sh restart apache
if app is lauched on your instance you can open it using http://address_of_VMInstance/yourapp
Upvotes: 1
Reputation: 1130
More explicitly - The firewall's job is simply to intercept disallowed incoming connections and silently drop them.
In this case, you: (a) see ping responses from the VM's public IP address, indicating that ICMP is not blocked by the firewall. (b) see a TCP RST packet sent by the VM in response to the TCP SYN packet your browser sent as it attempted to connect to a TCP server on the VM. This indicates that packets addressed to TCP port 80 are also passed by the firewall, as expected.
What's missing here is a server application on your VM that listens to connections on port 80, receives HTTP requests and responds. You might try running, say, Apache (or Nginx, which is even simpler to set up).
In answer to your other question - you don't need the second tcp:80 firewall rule - but if you want the default http rule to allow packets to your VM, you will need to a tag to your VM labelled "http-server".
Upvotes: 0
Reputation: 49
The error is CONNECTION_RESET. My guess is MEAN stack is not listening on port 80.
Upvotes: -1