To serve a local directory over HTTPS using ngrok, follow these steps:
-
Install ngrok:
- Download ngrok from the official website.
- Unzip the downloaded file.
- Move the
ngrokexecutable to a directory included in your system's PATH for easy access from the command line.
-
Authenticate ngrok:
- Sign up for a free ngrok account to obtain an authentication token.
- In your terminal, run:
Replace
ngrok config add-authtoken YOUR_AUTHTOKEN
YOUR_AUTHTOKENwith the token from your ngrok dashboard.
-
Serve the local directory:
- Navigate to the directory you want to serve:
cd /path/to/your/directory - Start a simple HTTP server using Python:
This command serves the current directory's contents at
python3 -m http.server 8000
http://localhost:8000.
- Navigate to the directory you want to serve:
-
Expose the local server with ngrok:
- In a new terminal window, run:
ngrok http 8000
- ngrok will display a forwarding URL, such as
https://abcd1234.ngrok.io, which securely tunnels to your local server.
- In a new terminal window, run:
By following these steps, you can share the https:// URL provided by ngrok to allow others to access your local directory's contents over the internet.
For more detailed information, refer to ngrok's Getting Started Guide.