📅  最后修改于: 2023-12-03 15:33:07.233000             🧑  作者: Mango
Ngrok is a great tool for developers who need to expose their localhost to the internet. It allows you to easily create tunnels to your localhost to make it publicly accessible without having to deploy your code to a server. In this tutorial, we will explain how to sign up for ngrok and get started using it.
First, you need to sign up for ngrok. Go to https://dashboard.ngrok.com/signup and create an account. You will need to provide your email address and create a password.
After you submit your information, you will receive an email asking you to verify your email address. Click the link in the email to verify your account.
Next, you need to install ngrok on your computer. Ngrok has clients for Windows, macOS, and Linux. You can download the client for your operating system from the ngrok download page.
Once you have installed ngrok, you need to connect your account to the client. To do this, open a terminal or command prompt and type the following command:
./ngrok authtoken <your-auth-token>
Replace <your-auth-token>
with the auth token from your ngrok dashboard. You can find your auth token on the ngrok dashboard.
After you enter the command, you should see a message that says "Authtoken saved to configuration file".
Now you're ready to start a tunnel! Open a terminal or command prompt and type the following command:
./ngrok http <port>
Replace <port>
with the port number of the server you want to expose. For example, if you're running a web server on port 8000, you would type ./ngrok http 8000
.
After you enter the command, ngrok will create a tunnel to your localhost and generate a public URL that you can use to access your server from the internet. You can find the URL in the console output:
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Account Michael Scott (Plan: Free)
Version 2.3.40
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://5b50ef21.ngrok.io -> http://localhost:8000
Forwarding https://5b50ef21.ngrok.io -> http://localhost:8000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
In this example, the public URL is http://5b50ef21.ngrok.io
.
That's it! You're now signed up for ngrok and ready to start using it to expose your localhost to the internet. With ngrok, you can easily test webhooks, APIs, and other applications that require a public URL without having to deploy your code to a server. Happy coding!