Building a website on an idle mobile phone – Android Termux+Hexo to build your own blog website [cpolar realizes public network access]

Article directory

  • 1. Install Hexo
  • 2. Install cpolar intranet penetration
  • 3. Public network remote access
  • 4. Fixed public network address

Hexo is a fast, clean and efficient blogging framework written in Nodejs. Hexo uses Markdown to parse articles, and in a few seconds, it can generate static web pages with beautiful themes.

The following describes how to install a personal hexo blog in Termux and combine it with the cpolar tool to achieve access in a public network environment.

1. Install Hexo

Hexo is written in Nodejs, so install node.js first, termux is also packaged, and install with one line of command:

pkg install nodejs

After installation, use the npm command to install hexo:

npm install hexo-cli -g

After the installation is complete, check the version information to check whether the installation is successful:

hexo -v

image-20230512133528614

Manually create a hexo directory:

mkdir hexo

enter directory

cd hexo

Initialize the Hexo environment

hexo init

Generate static files after initialization:

hexo g

start hexo

hexo s

After starting, we can see the address and port number of the access

image-20230512134826015

We open the browser, enter the above access link, you can see hexo

image-20230512135104828

The above startup method is to start hexo on the foreground interface, which is not very convenient for us to do other operations, so we change it to start in the background, first use the Ctrl + C key to stop hexo,

image-20230512140325029

Then we use nohup to start in the background. After starting, we can press the PID:

nohup hexo s &

image-20230512140634188

The way to close is also very simple, use the kill command:

kill -9 PID

2. Install cpolar intranet penetration

We have installed the hexo blog above. Next, we will install cpolar intranet penetration, and use cpolar to publish the hexo blog built on the mobile phone termux, so that the public network can also access the blog site built on the mobile phone intranet.

If you use cpolar intranet penetration, you don’t need a public network IP, and you don’t need to set up a router. It can map services under the local intranet to the public network by creating a secure tunnel. It is a safe intranet penetration tool.

First create a sources.list.d folder:

mkdir -p $PREFIX/etc/apt/sources.list.d

Add cpolar to download source files

echo "deb [trusted=yes] http://termux.cpolar.com termux extras" >> $PREFIX /etc/apt/sources.list.d/cpolar.list

update warehouse

pkg update

install cpolar

pkg install cpolar

Install termux service, note: After the installation is complete, remember to close and restart termux to take effect!!

pkg install termux-services

After restarting termux, then start cpolar

sv up cpolar

Set up autostart

sv-enable cpolar

This is to stop the cpolar service

sv down cpolar

cpolar.yml main configuration file path location

$PREFIX/etc/cpolar/cpolar.yml

Then enter http://localhost:9200 in the mobile browser to see the cpolar management interface, and log in with the account registered on the cpolar official website

image-20230509155942139

3. Public network remote access

Open the cpolar management interface in the mobile browser, we click on the tunnel management on the left dashboard – create a tunnel, above we see that the port number is 4000 through local access, so we want to create an http tunnel, Point to port 4000:

  • Tunnel name: customizable, be careful not to repeat
  • protocol: http
  • Local address: 4000
  • Domain Type: Choose a random domain name
  • Region: Select China VIP

Click Create

image-20230512150045998

After the creation is successful, open the online tunnel list, and you can see the address accessed by the public network. There are two access methods, one is http, the other is https

image-20230512150926656

Then we use one of the http addresses to visit in the browser, and we can see our Hexo blog interface, so that the remote access is configured

image-20230512151135860

4. Fixed public network address

The above creation is a free random address, which changes within 24 hours. In order to facilitate long-term and stable connection, we can fix the access address, which is called a fixed second-level subdomain name in cpolar. Of course, you can also configure and use your own domain name to access.

You need to upgrade to the basic package or above to support the configuration of second-level subdomains

Log in to the background of the cpolar official website, click Reserved on the left dashboard, find Reserve the second-level subdomain name, and reserve a second-level subdomain name for the http tunnel.

  • Region: select server region
  • Name: Fill in the second-level subdomain name you want to reserve (customizable)
  • Description: Remarks, which can be customized

image-20230516141511164

In this example, a second-level subdomain named hexoblog is reserved. After the subdomain name is successfully reserved, we copy the subdomain name, and then we need to configure it in the tunnel.

image-20230516141541897

Log in to the cpolar web ui management interface, click Tunnel Management on the left dashboard–Tunnel List, find the tunnel that needs to be configured with a second-level subdomain name, and click edit

image-20230516142410556

Modify the tunnel information and configure the second-level subdomain name into the tunnel:

  • Domain name type: choose secondary subdomain name instead
  • Sub Domain: Fill in the second-level subdomain we just reserved (in this case hexoblog)

After modification, click Update

image-20230516142441119

After the tunnel is successfully updated, click Status on the left dashboard–Online Tunnel List, and you can see the public network address of the tunnel, which has been updated to a second-level subdomain.

image-20230516142517920

Then we use one of the http addresses to visit in the browser, and we can see our Hexo blog interface, so that a fixed remote access to the hexo blog is configured [cpolar.cn has been filed, so there is no need for filing].

We only need to keep the tunnel online normally, and the public network users can access the blog website on the mobile phone termux through this public network address.

image-20230516143034891