How Do You Get a GCP Server to Present a Website on the Internet?

Problem scenario
You want to browse the web UI of a web application that you set up on a Linux machine in GCP.  How do you get a web service (e.g., Nginx, Apache web server, SonarQube or Jenkins) to work when the server is in Google Cloud Platform?

Solution
Prerequisites
This assumes you have deployed the web application.  If you want to deploy Nginx, see this link.  If you want to deploy Apache web server, see this link.  If you want to install SonarQube, see this link.  If you want to deploy Jenkins, see this link.

Procedures
Overview:  Create a firewall rule from the source IP address of your web browser. 

1.  After you are logged into GCP go to VPC Network -> Firewall Rules. 
2.  Click on "Create firewall rule".
3.  To find the source IP address go to the workstation where you will browse from and go to ipchicken.com
4.  The port may vary (e.g., for SonarQube you may need 9000 or for Jenkins you may need 8080).  If you want the application to work from any workstation, use the source IP address range of "0.0.0.0/0" with no quotes.  
6.  For a Tag, enter an alphanumeric string.   Remember the tag you give this rule.
7.  Next go to "Compute Engine" -> "VM Instances" page. 
8.  Click on the hyperlink for the VM that has the web service. 
9.  Click on "Edit" to modify the details. 
10.  In the "Network Tags" field, enter the unique tag you entered above (the alphanumeric string).  
11.  Go to the Firewalls section.  Click the boxes for "Allow HTTP traffic" and "Allow HTTPS traffic".
12.  Click "Save".  The changes will take effect after a few minutes.

Leave a comment

Your email address will not be published. Required fields are marked *