Forked from stephenbradshaw/python3_https_server.py
Last active
June 24, 2024 06:21
-
-
Save astrojuanlu/13c2803bab300d2a8f0e117475a7a1cc to your computer and use it in GitHub Desktop.
Python 3 Simple HTTPS server with Certbot (for Let's Encrypt)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Create a basic certificate using Certbot (for Let's Encrypt) and Ansible: | |
# https://github.com/geerlingguy/ansible-role-certbot | |
from http.server import HTTPServer, SimpleHTTPRequestHandler | |
import ssl | |
domain = "example.com" # Edit with your domain | |
httpd = HTTPServer(("0.0.0.0", 443), SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket( | |
httpd.socket, | |
keyfile="/etc/letsencrypt/live/{domain}/privkey.pem", | |
certfile="/etc/letsencrypt/live/{domain}/cert.pem", | |
server_side=True, | |
) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment