## Step 5: Set Up HTTPS with mkcert (Ubuntu/Debian) **1. Install mkcert (if not already installed):** ```bash sudo apt install libnss3-tools curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" chmod +x mkcert-v*-linux-amd64 sudo mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert ``` **2. Install local certificate authority:** ```bash mkcert -install ``` **3. Create certificates directory:** ```bash mkdir certs mkcert -cert-file certs/localhost+2.pem -key-file certs/localhost+2-key.pem localhost 127.0.0.1 ::1 ``` This creates: • certs/localhost+2.pem (certificate) • certs/localhost+2-key.pem (private key) **4. Install Uvicorn (ASGI server with SSL support):** Ensure you are at the project root and venv is activated: ```bash pip install uvicorn[standard] ``` **5. Update requirements.txt:** ```bash pip freeze > requirements.txt ``` **6. Create run.sh script (Linux):** ```bash cat > run.sh << 'EOF' #!/usr/bin/env bash uvicorn backend.asgi:application \ --host 127.0.0.1 --port 8000 \ --ssl-keyfile ./certs/localhost+2-key.pem \ --ssl-certfile ./certs/localhost+2.pem EOF chmod +x run.sh ``` Note: Replace backend with your project name if different. **7. Create VS Code launch configuration (optional):** For debugging in VS Code, create `.vscode/launch.json`: ```bash mkdir -p .vscode cat > .vscode/launch.json << 'EOF' { "version": "0.2.0", "configurations": [ { "name": "Django HTTPS (Uvicorn)", "type": "debugpy", "request": "launch", "module": "uvicorn", "args": [ "backend.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--ssl-keyfile", "./certs/localhost+2-key.pem", "--ssl-certfile", "./certs/localhost+2.pem", "--reload" ], "django": true, "justMyCode": true, "python": "${workspaceFolder}/venv/bin/python" } ] } EOF ``` This allows you to: - Run and debug Django with F5 in VS Code - Set breakpoints in your Django code - Automatic venv activation via the `python` path Note: Replace `backend` with your project name if different.