Member-only story
This time, I finished a Flask backend application running on GCP. As I want to change the virtual machine’s url to Https, we will need Let’s Encrypt, an open certificate authority. We will also use Nginx as our reverse proxy server.
We will follow these steps to achieve our goal:
- Install Nginx
- Install Certbot
- Modify Nginx configuration
- Run the flask application
Install Nginx
Although flask can also act as a server, it is not suitable for production. (Here is a nice post explaining it 😉) In order to enhance scalability, we can install nginx with the following command: (My machine is Ubuntu 18.04
)
apt install nginx
and adjust the firewall to enable both port 80
and port 443
:
ufw allow 'Nginx Full'
If you are eager to learn more details about the installation, here is a detailed tutorial. But the two commands above will be sufficient for now 👌
Install Certbot
Certbot is a highly recommended tool that automatically enables HTTPS on our website. By following the steps in its official tutorial, the GCP VM should get a Https address: