Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Linux | Red Hat Certified | IT Technology | Operations Engineer
👇 Join the technical exchange QQ group of 1000 people Note: [Public Account] to pass faster

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

1. Install Nginx

Installing Nginx on Raspberry Pi is also very simple, it can be installed directly using the apt command, first update the repository

sudo apt update

Install updates

sudo apt upgrade

After the update, install the Nginx package

sudo apt install nginx

Start Nginx

sudo /ect/init.d/nginx start

After starting, we can enter the Raspberry Pi local IP:80 port in an external browser to access Nginx

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

2. Install cpolar

Use the one-click installation script for cpolar:

curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

Add the service to the system

sudo systemctl enable cpolar

Start the cpolar service

sudo systemctl start cpolar

Check the service status

sudo systemctl status cpolar

Restart the cpolar command (use when needed)

sudo systemctl restart cpolar

Then in an external browser use the Raspberry Pi local IP+:9200 port to access the cpolar management interface

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Log in using the account registered on the official website to operate the tunnel.

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

3. Configure domain name to access Nginx

We create a random tunnel on the cpolar management interface for port 80:

Tunnel Name: Custom, do not repeat Protocol: http Local Address: 80 Port Type: Random Domain Region: China

Click to create

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Then open the online tunnel list to view the public address of the created tunnel, there are two access methods by default, one is http, the other is https, copy the http address

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Open the browser and use the above http public address to access, you can see the nginx welcome page, thus the remote access is set up

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

4. Fixed domain name access

It should be noted that the above steps use a random temporary address, this public address will change randomly within 24 hours. Next, we will configure a fixed address that will not change, and after setting, you will not need to modify the address every day.

You need to upgrade to the basic package or above to support configuring a fixed domain name

Log in to the cpolar official website backend, click on the reserved section in the left dashboard, find the reserved secondary subdomain, and reserve a secondary subdomain for the http tunnel.

Region: Choose the server region Name: Fill in the secondary subdomain you want to reserve (customizable) Description: Custom input

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

In this example, we reserve a secondary subdomain named nginxtest. After successfully reserving the subdomain, we will copy the subdomain, and then need to bind it to the tunnel.

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Log in to the cpolar web UI management interface. Click on the left dashboard’s tunnel management – tunnel list, find the tunnel that needs to configure the secondary subdomain, and click edit on the right

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Modify the tunnel information and configure the secondary subdomain into the tunnel:

Domain Type: Change to select secondary subdomain

Sub Domain: Fill in the secondary subdomain we just reserved (in this example, nginxtest)

After modification, click update

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

After the tunnel update is successful, click on the left dashboard’s status – online tunnel list, you can see the public address of the nginx tunnel has been updated to the secondary subdomain, copy the public address.

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Open the browser, let’s test the access to the configured secondary subdomain, if the nginx welcome page appears, it indicates success and can be accessed normally. Now, we have created a unique private secondary subdomain for the entire network.

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

5. Configure static site

Enter the nginx resource directory, this directory is the default resource directory that nginx looks for

cd /var/www/html

To make the content of the site more meaningful, we will download and deploy a simple static demo site – Meditation Relaxation Site.

sudo wget https://www.cpolar.com/static/downloads/meditation-app-master.tar.gz

Unzip

sudo tar xzf meditation-app-master.tar.gz

Then open the browser and enter the public address we configured above plus the resource path: /meditation-app-master, you can see our configured site, and remote access is also possible.

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP

Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP
Achieve Intranet Penetration with Raspberry Pi and Nginx Without Public IP
Course consultation add: HCIE666CCIE
↑ Or scan the QR code above ↑
What technical points and content do you want to see
You can leave a message below to tell Xiao Meng!

Leave a Comment

×