SSL for HTTPS with Apache server - Flask web development with Python 35

sentdex · Beginner ·🛠️ AI Tools & Apps ·10y ago

Key Takeaways

Acquires and deploys an SSL certificate using LetsEncrypt with Apache server and Flask web development with Python

Full Transcript

what's going on everybody welcome to another python with flask web development tutorial in this tutorial I'm going to be showing you guys how to utilize SSL so you can have https on your website we're going to be using let's encrypt for this and this is totally free and it's actually really really simple especially with Apache uh which is what we're using with flask so let's go ahead and get started so the website that I'm going to add https or ssl2 is cyber. currently you can you go there and it's just straight up HTTP and I think it's really important that we encrypt this website so let's go ahead and I'm going to move this aside and this is the website for let's encrypt it's just literally let's encrypt.me steps plus one more thing is really all you need to do but actually there is one more thing we have to do we have to kind of prepare ourselves for this so um coming back over here let me just show you um currently let's see if this is even handled no uh currently like I can bring over cyber. but if I go www. cyber. I get the Apache configuration page now I've shown you guys one way to handle for this but it turns out there's a better way to handle for www and every other um kind of subdomain basically uh so the first thing that we're going to go ahead and do is we're going to go do uh Nano SLC Apache 2 sites Avail available and then RS is was flask app.com go ahead hit enter there and you'll see here we've got server name cyber. and the way we worked around this before was literally copying all of this pasting another one and just changing the server name to cyber. uh www. server or www. cyber. anyway uh but that's not going to work that's going to make uh let's encrypt angry and we won't be able to do both names so instead what we'll do is we have server name a cyber. but you can have a server Alias so we'll do server Alias and server Alias is going to be server Alias will be www. cyber. and um that's really all you have to change so let's go ahead and control X yes good uh and then we're going to service Apache to restart and um that may not that should happen pretty quick actually that should be done yeah so now www. cyber Dio works of course if you don't if like www. cyber. doesn't point to anything I.E if you go to your your DNS record and you don't have a c name for www it's not going to work anyways but this is assuming you added a c name for www okay so moving this over um what we're going to do now is uh we're going to do the let's encrypt where did I stuff let's encrypt I have too many monitors okay so these are the three steps you want to take currently we're in the root user directory probably don't want to stuff it there so we're going to change directory into VAR um actually H let's change directory this will just put us probably back in root let's CD um back to this and then let's encrypt we'll put it here that doesn't exist so let's um M let's encrypt CD let's encrypt great so now we're going to run these three statements now you might not have jit so you want to make sure that you have it so just do apptg install git yes great once we have that I'm just going to be copy paste that's done the next one is to to just CD into let's encrypt hopefully that double name won't get us in trouble um and then we're going to run this Auto let's encrypt Auto help okay and then whenever this is done we'll be ready to um actually add the SSL certificate and this part's actually really easyy it's a little harder if you have a different um server backend but Apache is just like all automated here still waiting on this so let's take forever so how's the weather I'll put this picture up I like that comic I don't want to have to pause this everyone else is probably having to wait this long but this is taking a long time I guess I'll pause okay it's done it actually pretty much finished as soon as I hit pause as as it would be so anyway um hopefully it didn't take that long for you but I wanted to pause just in case it was going really quick and you guys were just waiting on me so now what we're going to do is is period slash let's encrypt let's encrypt and then uh Das Auto no space there-- Apache d d and then this is your- D for domain and then one of the domains is going to be cyber. and then- D again the other domain is going to be w ww. cyber. everything looks good we'll go ahead and hit enter here and this process can sometimes take a little bit too um but basically what it's going to do okay first ask for your email address this is kind of silly I don't know why they I wish it was optional if you skip it you can skip it um and it just kind of yells at you a little bit but if you ever like lost anything you would just regenerate a key like it's so simple to regenerate the key so I'm pretty sure I would just do that so anyway yeah read the terms and all that blah blah blah blah hit agree this might take a second again normally it's even faster than this I'm surprised it's taking as long as it's taking um I saw an error I don't know why I did that but uh anyway you can either choose to allow people to have HTT to like access via HTTP or you can choose the secure which basically forces it'll redirect all um all requests to be over https uh so I'm going to go ahead hit okay here and congratulations is done you can test your configuration by going to either of these um examples because those are the both domains that we did um but I'm not really going to worry about that and then when you're all done you can come over and just literally refresh and boom you now have https and then we can also go to the regular version and again that's https as well so now you have https it was totally free and it was very very fast so that's pretty cool if you're like me I was like super excited when when it was like that simple so if you're using engine X I have a version for for that as well it's a little more in-depth it's like a few extra steps but it's really not that bad um so I'm moving this over uh one thing I'll just draw your attention to is normally getting s first of all getting an SSL certificate is the pain in the butt getting it all installed and set up pain in the butt everything is just so difficult but this was just s super easy so normally it and it also costs a lot of money so um one thing that'd be nice if you have the money to spare go to Let's encrypt.me certificate once every 90 days um you you you can do it like once a day I mean you might actually probably run out then but like once a month or once ever you can set an alert somewhere just to do it and literally all you need to do to re uh do the certificate is literally that same thing we just did you just run this command and it'll reissue you a certificate and that's that's it it's so simple I think it's awesome um couple things to note if you have any links on your website obviously for us we generated our are links via the um generally a variable but if you have any links uh and you're you're linking to http address you will break this connection it'll be like a Sil it'll be like black and white rather than green that's what's happening you you've got some insecure elements on the page one thing you can do is every time you link to something rather than linking to http or https SL SL you link to Simply slash slash in the URL and all that and that will work both with HTTP or https but if you use the static variables and stuff especially for elements within your website that's already handled for in the back end anyway um that's all if you have questions comments concerns something didn't work out for you whatever uh let me know leave your questions comments below uh otherwise as always thanks for watching thanks for all the support subscriptions and until next time

Original Description

In this tutorial, you are shown how to use LetsEncrypt to acquire an SSL certificate and then how to deploy it to your website so you're using HTTPS. Text-based tutorial: https://pythonprogramming.net/ssl-https-letsencrypt-flask-tutorial/ https://letsencrypt.org https://pythonprogramming.net https://twitter.com/sentdex https://www.facebook.com/pythonprogramming.net/ https://plus.google.com/+sentdex
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

Related AI Lessons

Up next
How to Open HPL Files (HP-GL Plotter)
File Extension Geeks
Watch →