Search code examples
flaskgoogle-cloud-platformgunicornflask-restfulapache-superset

How to host flask app on GCP using gunicorn?


I am trying to host my superset app on GCP using Gunicorn on a development mode. Here's my configuration:

App Installation instructions: https://superset.incubator.apache.org/installation.html App configuration instructions: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04

Note that I am turning on port listening using:

sudo ufw allow 8088

To run the app:

superset run -p 8088 -h 0.0.0.0

The link which I want to access: http://gcp_external_ip:8088

But it's not responding.

Note that I have setup for all HTTP and https traffic: enter image description here

Here's my command shell: enter image description here

Kindly let me know where am I going wrong? I am not able to access the server from my other system: enter image description here

External ping is also happening: enter image description here


Solution

  • You don't need to change port on which your app is exposed to the Internet - if you're OK with 8088 then use it.

    Just make sure that you create a GCP firewall rule to let the traffic in. By default HTTP server and HTTPS server open ports 80 and 443 respectively. Port 8088 is blocked by default.

    Example firewall rule to open up port 8080 for an instance with "tag1" tag from all IP's:

    gcloud compute --project=myproject firewall-rules create port8088 --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:8088 --source-ranges=0.0.0.0/0 --target-tags=tag1

    Also - assign "tag1" tag to the VM you want to "unblock".