Skip to content

Sample for building a web application with Python3, Flask, Gunicorn, Nginx (HTTPS) and Docker.

License

Notifications You must be signed in to change notification settings

kevin-appl/python-flask-docker-https

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-flask-docker-https

Sample for building a web application with Python3, Flask, Gunicorn, Nginx (HTTPS) and Docker.

Flask's built-in server is not suitable for production. Therefore, we deploy our Flask application to Gunicorn (WSGI server). Gunicorn is best used behind a proxy. In our case, we use NGINX as a reverse proxy. Docker containers make it easy to deploy this architecture on a host system.

overview

Getting started

First install Docker on your system.

If you are on Linux, add your user to the UNIX group called docker. For more details, check out Docker post-installation steps. Reboot your system to apply changes:

sudo usermod -aG docker $USER
sudo reboot

Now generate a self-signed SSL certificate (cert.pem, key.pem):

openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365

By default, the Nginx server in this project wants a SSL certificate stored in /var/ssl on your local machine. You can move your generated cert.pem and key.pem file there.

If you prefer to use a different directory (for example, because you are on Windows), you can change it. Simply open the file .env and replace /var/ssl with your preferred directory.

Now open a terminal in your project directory and launch your web application:

docker compose up

Open in web browser: https://127.0.0.1

About

Sample for building a web application with Python3, Flask, Gunicorn, Nginx (HTTPS) and Docker.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published