Using cpolar for Java SpringBoot API Testing and Fixed Public Tunnels
This tutorial demonstrates how to set up a SpringBoot Java service, expose its API through cpolar's internet‑penetration tunnel, configure a fixed sub‑domain, and use the cpolar listener to monitor and replay requests, providing a complete workflow for backend developers.
Preface
In a front‑back separation project, you can use cpolar's internal‑network penetration to simulate a public network environment for remote debugging of local service interfaces; this tutorial uses a Java backend API as an example.
1. Local Environment Setup
1.1 Environment Parameters
JDK 1.8
IDEA
SpringBoot
Maven
Tomcat 9.0
Postman
1.2 Build a SpringBoot Service Project
Create a SpringBoot project and implement a simple POST interface for demonstration.
@RestController
@RequestMapping("/test")
public class InterfaceTest {
/**
* Test interface
* @param data
* @return Map
*/
@PostMapping("/interTest")
public Map
interTest(@RequestBody Map
data){
System.out.println(data);
if (data.size()>0){
return data;
}
data.put("code","404");
return data;
}
}2. Internal Network Penetration
We use cpolar , which supports HTTP/HTTPS/TCP, has no traffic limit, and does not require a public IP.
2.1 Install and Configure cpolar
Official website: https://www.cpolar.com/
2.1.1 Windows
Download the Windows version from the website and install with default settings.
2.1.2 Linux
Domestic installation:
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bashOverseas short‑link installation:
curl -sL https://git.io/cpolar | sudo bashCheck version to confirm successful installation:
cpolar versionToken authentication: obtain your token from the cpolar console and run:
cpolar authtoken xxxxxxxSimple tunnel test:
cpolar http 8080Press Ctrl+C to exit.
Add cpolar as a system service:
sudo systemctl enable cpolarStart the service:
sudo systemctl start cpolarCheck service status (image omitted).
2.2 Create Tunnel Mapping for Local Port
After installing cpolar, open the browser to http://localhost:9200 and log in to the cpolar web UI.
In the dashboard, go to Tunnel Management → Create Tunnel and set up an HTTP tunnel for the local Tomcat port 8080.
Tunnel name: custom (avoid duplicates)
Protocol: HTTP
Local address: 8080
Domain type: free random domain
Region: China VIP
After creation, view the generated public address in the Online Tunnel List and copy it.
2.3 Test Public Address
Use Postman to send a POST request to the copied public address plus the API path, with JSON parameters. Debug the service to verify the request reaches the interface.
3. Fixed Public Address
The random public address created by cpolar changes within 24 hours, which is inconvenient for long‑term remote access. You can reserve a secondary sub‑domain to obtain a fixed address.
Note: you need to upgrade the cpolar plan to at least the Basic tier; each tier provides different bandwidth. (cpolar.cn is already备案)
3.1 Reserve a Sub‑Domain
Log in to cpolar, go to the Reserve section, choose a secondary sub‑domain, set a name, and reserve it. Copy the reserved sub‑domain name after success.
3.2 Configure the Sub‑Domain
In the cpolar web UI, edit the previously created 8080 tunnel and set the Domain Type to "Secondary Sub‑Domain" and fill in the reserved sub‑domain (e.g., test01). Click Update.
Domain Type: Secondary Sub‑Domain
Sub Domain: test01
After updating, the online tunnel list shows the new fixed public address; copy it.
3.2 Test Using Fixed Public Address
In Postman, call the fixed HTTP address. Debug the backend to confirm the request reaches the interface.
4. cpolar Listener
You can open the cpolar listener at http://localhost:4040 to view request logs, replay requests, and accelerate testing.
4.1 Enable Listening
Select the configured HTTP tunnel, edit it, and enable the listener in Advanced Settings.
4.2 Request Listening
Visit http://localhost:4040 in a browser. After sending a request to the backend, the listener displays request method, data, path, status, and result, greatly improving debugging efficiency.
Backend Exclusive Technical Group
Build a high‑quality technical community; developers, recruiters, and anyone interested are welcome to join, share job referrals, and help each other improve.
Maintain civil discussion, focusing on technical exchange , job referrals , and industry topics .
Advertisements are prohibited; beware of private scams.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.