Let the self-built website have its own domain name (2)

In the previous article, we made the link of the new domain name take effect by setting up a new domain name on the server and directing the new domain name to the backend entry of ngrok's data channel. Next, we need to set up ngrok on the local Raspberry Pi side, so that when ngrok is running in the background, it can also correctly link the data request of the new domain name to our Raspberry Pi website.

First, we need to test whether ngrok can correctly point the new domain name to our Raspberry Pi local website when ngrok is running in the foreground.

Enter the command locally

cpolar http -hostname=dev.bestexpresser.com 80

If the following content is displayed, it means that the new domain name (in this example, the new domain name is http://dev.bestexpresser.com ) can correctly access the local website.

Of course, we can also open the browser when ngrok is running in the foreground, enter the new domain name we set, and see if the browser can correctly access the local Raspberry Pi website.

After confirming that the new domain name can correctly point to our local website, we can set up the local ngrok. First enter the command to open the ngrok configuration file:

nano /usr/local/etc/cpolar/cpolar.yml

Then under the website tunnel, delete the subdomain line and add a line of hostname parameter

After the parameters are modified, exit the ngrok configuration file editing, and then enter the relevant commands in the command line to start a separate website tunnel to test the parameters we modified. As long as the following figure is displayed, it means that the configuration we entered has taken effect successfully:

cpolar start website

At this point, we can enter the command line to restart ngrok, and let our new domain name continue to point to the website on the local Raspberry Pi.

sudo systemctl restart cpolar

It should be noted that custom domain names in domestic regions need to be filed in advance before they can be deployed (including cn, cn_vip, cn_top), and foreign countries do not need to be filed (including us and hk regions). Among them, domain names in the cn region are automatically displayed as whitelists; domain names in the cn_vip and cn_top regions require manual review to enter the whitelist (you can contact QQ customer service on the ngrok official website to assist you in submitting an application for a domain name to enter the whitelist). If the domain name has not been filed, the us and hk regions can also be used, and there is no need to apply for the domain name to enter the whitelist.

From the introduction of these two articles, it can be seen that it is not a very complicated operation to obtain a new domain name for our website, but this step is necessary for friends who want to make the URL of their website look special. Less (for example, for business customers, those who want their website to be consistent with the company name; or those who want to rename the URL to make it have a special commemorative meaning). But no matter what kind of domain name the local website wants to use, to connect it to the public Internet so that it can be accessed normally by everyone, it is inseparable from the help of ngrok, which is just one of the many functions of ngrok. If you have any questions about the use of ngrok, you are welcome to communicate with us, and we will provide you with assistance within our ability.

Guess you like

Origin blog.csdn.net/probezy/article/details/123713258