Remote debugging with springboot server-side? Try HTTP for service listening

Time:2023-12-22
Article Catalog

preamble

Front-end separation project, in the call interface debugging, we can cpolar intranet penetration will be the local server-side interface simulation of the public network environment remote call debugging, this tutorial we Java server-side interface as an example.

1. Local environment setup

1.1 Environmental parameters

  • JDK1.8
  • IDEA
  • SpringBoot
  • Maven
  • Tomcat9.0
  • Postman

1.2 Build springboot service project

build a springboot service project, write an interface, in order to better visualize, here to create a pos request interface
@RestController
@RequestMapping("/test")
public class InterfaceTest {
    
    /**
     * :: Testing of interfaces
     * @param data
     * @return Map<String,String>
     */
    @PostMapping("/interTest")
    public Map<String,String>interTest(@RequestBody Map<String,String> data){
        System.out.println(data);

        if (data.size()>0){

            return  data;
        }

        data.put("code","404");
        return data;
    }
}

2. Intranet penetration

Here we use cpolar for intranet penetration, supports http/https/tcp protocols, unlimited traffic, no need for a public IP, no need to set up a router, easy to use.

2.1 Installing and configuring cpolar intranet penetration

cpolar official website:https://www.cpolar.com/

2.1.1 windows

After entering the cpolar official website, download the windows version version, double click the installation package all the way to the default installation.

2.1.2 linux

  • cpolar installation (for domestic use)
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • or cpolar short link installation method: (for foreign use)
curl -sL https://git.io/cpolar | sudo bash
  • Check the version number, there is a normal display of the version number that is successfully installed
cpolar version
  • token authentication
Log in to the backend of the cpolar website, click on Authentication on the left side, check your authentication token, and after that paste the token in the command line
cpolar authtoken xxxxxxx
Remote debugging with springboot server-side? Try HTTP for service listening
  • Simple penetration test
cpolar http 8080
Press ctrl+c to exit
  • Adding services to the system
sudo systemctl enable cpolar
  • Start the cpolar service
sudo systemctl start cpolar
  • Check Service Status
Remote debugging with springboot server-side? Try HTTP for service listening

2.2 Creating a Tunnel to Map Local Ports

After cpolar is successfully installed, access local port 9200 on your browser [http://localhost:9200], log in using the cpolar account. Remote debugging with springboot server-side? Try HTTP for service listening Click Tunnel Management – Create Tunnel on the left dashboard to create a tomcat port 8080 http tunnel
  • Tunnel name: can be customized, be careful not to duplicate the existing tunnel name.
  • Protocol: choose http
  • Local address: 8080
  • Domain Type: Free random domain name selection
  • Region: Select China vip
strike (on the keyboard)establish Remote debugging with springboot server-side? Try HTTP for service listening After the tunnel is successfully created, click Status – Online Tunnel List on the left to view the generated public address, and then copy the address. Remote debugging with springboot server-side? Try HTTP for service listening

2.3 Testing public network addresses

Here to Postman interface debugging tool to send requests to the interface, in postman to create a post request method. Enter the public address of the copy plus the path to the interface, use JSON format for the parameters, set the parameters and click the Remote debugging with springboot server-side? Try HTTP for service listening Debugging interface debugging interface in the service interface to see whether the request to enter the interface, into the interface that the call is successful Remote debugging with springboot server-side? Try HTTP for service listening

3. Fixed public network address

Since the above tunnel created using cpolar uses a random public address that changes randomly within 24 hours, it is not conducive to long-term remote access. Therefore, we can configure a second-level subdomain for it, which is a fixed address that does not change randomly
Note that you need to upgrade the cpolar package to the basic package or above, and each package corresponds to a different bandwidth. [cpolar.cn has been filed].

3.1 Reservation of a second-level subdomain

Login to cpolar official website, click on the left side of the reservation, choose to reserve a second-level sub-domain, set a second-level sub-domain name, click on the reservation, after the reservation is successful, copy the name of the reserved second-level sub-domain. Remote debugging with springboot server-side? Try HTTP for service listening

3.2 Configuring second-level subdomains

interviewshttp://127.0.0.1:9200/To configure a tunnel, log into the cpolar web UI management interface, click Tunnel Management – Tunnel List on the left dashboard, find the 8080 tunnel you want to configure, and click Edit on the right side. Remote debugging with springboot server-side? Try HTTP for service listening Modify the tunnel information to configure a successfully reserved second-level subdomain into the tunnel
  • Domain type: select a second-level subdomain
  • Sub Domain: Fill in the second-level sub domain name of the successful reservation, in this case, test01.
strike (on the keyboard)update Remote debugging with springboot server-side? Try HTTP for service listening After the update is complete, open the list of online tunnels, you can see that the public address has changed, the address name has also changed to the name of the reserved second-level sub-domain, copy it down! Remote debugging with springboot server-side? Try HTTP for service listening

3.2 Testing the use of a fixed public address

Open postman, and call it with a fixed http address. Remote debugging with springboot server-side? Try HTTP for service listening The same server-side debugging debugging to see if the request to enter the interface, into the interface that success! Remote debugging with springboot server-side? Try HTTP for service listening

4. Cpolar listener

We can also use the cpolar listener (http://localhost:4040) View the interface request logs to deal with a nasty bug. or even replay the request message packet to speed up the request for testing. click the Replay button to resend that HTTP signaling request instead of manually re-triggering the operation. The following describes listening to requests using the cpolar listener.

4.1 Enabling Listening

Select the http tunnel we just created and configured and click on the right side of thecompiler Remote debugging with springboot server-side? Try HTTP for service listening Open the advanced settings and turn on listening. Remote debugging with springboot server-side? Try HTTP for service listening

4.2 Request listening

accessing local port 4040 in a browser.http://localhost:4040 Remote debugging with springboot server-side? Try HTTP for service listening After sending a request to the server , here will display the relevant request log , you can see the request mode , the requested data , interface path , and return status and results , greatly improving the debugging efficiency . Remote debugging with springboot server-side? Try HTTP for service listening Reprinted from the cpolar intranet penetration article:Springboot server-side interface public network remote debugging, and the implementation of HTTP service listener

Recommended Today

Resolved the Java. SQL. SQLNonTransientConnectionException: Could not create connection to the database server abnormal correctly solved

Resolved Java. SQL. SQLNonTransientConnectionException: Could not create connection to the database server abnormal correct solution, kiss measuring effective!!!!!! Article Catalog report an error problemSolutionscureexchanges report an error problem java.sql.SQLNonTransientConnectionException:Could not create connection to database server Solutions The error “java.sql.SQLNonTransientConnectionException:Could not create connection to database server” is usually caused by an inability to connect to the […]