Search code examples
apachegoogle-cloud-platformvirtual-machinegoogle-compute-enginegoogle-cloud-networking

How To open ports on Ubuntu in Google cloud platform


I am trying to run an ubuntu apache server on Google cloud platform, I have created the VM instances but I can't connect to any other port apart for from 80 and 22. Here are all the things I've tried so far:

  • Created Firewall rules to allow ingress traffic to ports 21,20 and 443.enter image description here

    • Created FireWall rules on the Ubuntu Machine itself

enter image description here

The only ports that seem to be open are the 80 and 22.

enter image description here

I also allowed both HTTP and HTTPS access in the VM settings enter image description here

So Basically, what I am trying to do is to open ports on my server. I'm not sure what am doing wrong.


Solution

  • You have already installed apache, and it's running on the port 80 as you can see on the nmap test, a closed port just mean that there's no application running on that port, this is different to filtered, see this for more information, this confirms that your firewall rules are correct (you are allowing traffic from all sources 0.0.0.0/0). By now you should be able to access your website on the port 80, if not I suggest you to follow this GCP guide.

    So, if you want to run apache on the port 443 you just need to change its configuration (basically you will need to get a certificate for your server, configure some related parameters and then create a virtualhost listening on the 443 port, there are many guides on the internet for this just google for "enable https apache [your_OS]"), that should be enough since the firewall rules on GCP and your instance appear to be properly configured.