Network access method and device, equipment and storage medium
The SSH service is configured in SOCKS proxy mode, and the proxy server is used to achieve secure communication in different network environments. This solves the problems of complex configuration and high maintenance costs in the existing technology, and achieves safe, simple and cost-effective network communication, and has Good scalability and stability.
Patent Information
- Application Number
- CN202410817144.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-09-06
AI Technical Summary
When existing methods achieve secure Internet access in an isolated production environment, configuration is complex and maintenance costs are high, which can easily lead to network performance degradation, and there is a lack of simple and cost-effective solutions.
The SSH service is configured in SOCKS proxy mode to achieve secure communication between different network environments through the proxy server. It uses SSH's extensive support and built-in security mechanism to reduce technical thresholds and maintenance costs, and improves the network through cluster processing and failover mechanisms. Communication stability and availability.
It achieves safe, simple and cost-effective network communication between different network environments, reduces configuration complexity and maintenance costs, and has good scalability and adaptability to cope with changing network conditions and security requirements.
Smart Images

Figure CN118611952A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet access, and in particular to a network access method, device, equipment and storage medium. Background Art
[0002] Currently, methods for achieving secure Internet access in isolated production environments involve complex network configurations, such as configured virtual private networks (VPNs) and customized firewall rules. Although existing methods can provide network security, they often involve complex settings and high maintenance costs, and are prone to network performance degradation due to improper configuration or technical limitations. Therefore, there is an urgent need to provide a secure, simple and cost-effective network access method. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present disclosure provide a network access method, apparatus, device and storage medium, which realize safe, simple and cost-effective network communication between clients in different network environments.
[0004] In a first aspect, an embodiment of the present disclosure provides a network access method, the method comprising:
[0005] Enabling an SSH service on at least one original server and configuring the SSH service to a SOCKS proxy mode to obtain at least one proxy server;
[0006] In response to a proxy configuration request of a first client, determining a target proxy server assigned to the first client among the at least one proxy server;
[0007] The network communication information of the target proxy server is sent to the first client, so that the first client uses the target proxy server to access the second client based on the network communication information, wherein the first client and the second client are in different network environments.
[0008] Optionally, configuring the SSH service to a SOCKS proxy mode to obtain at least one proxy server includes:
[0009] Generate a configuration command, wherein the configuration command includes a service identifier and configuration information;
[0010] Sending the configuration command to a target SSH service corresponding to the service identifier, so that the target SSH service performs configuration of a SOCKS proxy mode based on the configuration information;
[0011] Among them, the configuration information includes the communication port, data transmission method and current executable functions of the target SSH service running on the target original server. The target original server refers to the original server in the at least one original server where the target SSH service is enabled, and the current executable functions do not include remote command functions.
[0012] Optionally, after configuring the SSH service to SOCKS proxy mode and obtaining at least one proxy server, the method further includes:
[0013] Configure security rules corresponding to the firewall and security group on the at least one proxy server, wherein the security rules include at least one terminal that can configure the at least one proxy server and the communication port accessible to the at least one terminal, and the at least one terminal includes the first client.
[0014] Optionally, determining a target proxy server assigned to the first client in the at least one proxy server includes:
[0015] Determining a load requirement of the first client in the proxy configuration request;
[0016] performing clustering processing on the at least one proxy server to obtain a proxy cluster;
[0017] Load balancing is performed on the proxy servers in the proxy cluster according to the load demand, and a target proxy server allocated to the first client is determined.
[0018] Optionally, after clustering the at least one proxy server to obtain a proxy cluster, the method further includes:
[0019] Configuring a failover mechanism for the proxy cluster, wherein the failover mechanism is used to characterize the corresponding relationship between the failure state of the proxy server and the failure processing;
[0020] Acquire working data of each proxy server in the proxy cluster, and generate control instructions for each proxy server based on the working data and the failover mechanism;
[0021] Executing the control instruction to update the proxy cluster to obtain an updated proxy cluster;
[0022] The step of performing load balancing on the proxy servers in the proxy cluster according to the load demand and determining a target proxy server assigned to the first client includes:
[0023] Load balancing is performed on the proxy servers in the updated proxy cluster according to the load demand, and a target proxy server assigned to the first client is determined.
[0024] Optionally, the generating a control instruction for each proxy server based on the working data and the failover mechanism includes:
[0025] For each proxy server, when it is determined according to the working data that each proxy server is in a healthy state, a first instruction is generated, where the first instruction is an instruction for controlling each proxy server to perform load balancing; or,
[0026] In the case where it is determined according to the working data that each proxy server is in an overload state, generating a second instruction, wherein the second instruction is an instruction for controlling each proxy server to exit load balancing, and the overload state means that the load of each proxy server exceeds the rated capacity; or
[0027] In the case where it is determined according to the working data that each proxy server is in a failed state, generating a third instruction, wherein the third instruction is an instruction for controlling each proxy server to exit the proxy cluster, and the failed state is that a network failure occurs in each proxy server;
[0028] The control instruction includes the first instruction, the second instruction and the third instruction.
[0029] Optionally, the first client refers to at least one of a Kubernetes cluster, a container for mirroring, and a Java application;
[0030] The network communication information includes the communication address of the target proxy server and the communication port of the target proxy server running SOCKS;
[0031] The Kubernetes cluster is used to set the communication address and the communication port as environment variables in the deployment description file of the node;
[0032] The container is used to set the communication address and the communication port as environment variables in a text file for building an image;
[0033] The Java application is used to set the communication address and the communication port through Java virtual machine startup parameters.
[0034] In a second aspect, an embodiment of the present disclosure provides a network access device, the device comprising:
[0035] A configuration unit, configured to enable an SSH service on at least one original server and configure the SSH service to a SOCKS proxy mode to obtain at least one proxy server;
[0036] a determining unit, configured to determine, in response to a proxy configuration request of a first client, a target proxy server assigned to the first client from among the at least one proxy server;
[0037] The sending unit is used to send the network communication information of the target proxy server to the first client, so that the first client uses the target proxy server to access the second client based on the network communication information, wherein the first client and the second client are in different network environments.
[0038] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0039] Memory;
[0040] Processor; and
[0041] Computer programs;
[0042] The computer program is stored in the memory and is configured to be executed by the processor to implement the network access method as described above.
[0043] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the network access method as described above when executed by a processor.
[0044] The network access method provided by the present disclosure enables the SSH service on at least one original server, and configures the SSH service to SOCKS proxy mode to obtain at least one proxy server; in response to the proxy configuration request of the first client, determines the target proxy server assigned to the first client in the at least one proxy server; sends the network communication information of the target proxy server to the first client, so that the first client can access the second client in a different network environment from the first terminal by using the target proxy server based on the network communication information. The method provided by the present application realizes safe, simple and cost-effective network communication between clients in different network environments by configuring at least one proxy server. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0047] Figure 1 A flowchart of a network access method provided by an embodiment of the present disclosure;
[0048] Figure 2 A schematic diagram of the structure of a proxy cluster provided in an embodiment of the present disclosure;
[0049] Figure 3 A schematic diagram of the structure of a network access device provided by an embodiment of the present disclosure;
[0050] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0051] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0052] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0053] Specifically, in existing network communication configurations, it is often difficult to achieve both security and flexibility. Although existing methods such as VPN and customized firewalls can provide security, they often involve complex configurations and high maintenance costs, and the impact on network performance cannot be ignored.
[0054] In view of the above technical problems, the embodiment of the present disclosure provides a network access method, which adopts a SOCKS (firewall secure session conversion protocol, Protocol for sessionstraversal across firewall securely) proxy solution based on SSH (Secure Shell Protocol, Secure Shell), which is applicable to a variety of business scenarios and technical levels. Among them, SSH has wide support, built-in security mechanism and relatively low requirements for system resources. By using the widely supported SSH, the deployment and configuration process is simple and direct, which greatly reduces the technical threshold and maintenance cost. When resources are effective, it can also achieve secure communication of the network safely, simply and efficiently. In addition, the extensibility and adaptability of future technologies are fully considered. With the growth of application requirements and the evolution of network security threats, the present application can be responded to by simply updating and expanding existing proxy servers through simple configuration. In addition, through clustered proxy services and high-availability configurations, it can be foreseen that the integration of more advanced network monitoring and threat management technologies, such as automated traffic analysis and anomaly detection systems, will further enhance the security and practicality of the present application. It is specifically described in detail by one or more of the following embodiments.
[0055] Figure 1 A flowchart of a network access method provided by an embodiment of the present disclosure, which is applied to Figure 3 The network access device shown specifically includes: Figure 1 The following steps S101 to S103 are shown:
[0056] S101, enabling an SSH service on at least one original server, and configuring the SSH service to a SOCKS proxy mode, to obtain at least one proxy server.
[0057] It is understandable that the SSH service is enabled on one or more independent servers, and the SSH service is a protocol used for secure remote login and other secure network services on an insecure network. The one or more independent servers refer to at least one original server. Subsequently, the original server with the SSH service enabled is configured as a SOCKS proxy mode, or the SSH service is configured as a SOCKS proxy mode to obtain at least one proxy server, wherein the proxy server refers to the original server with the SSH service enabled and configured as a SOCKS proxy mode. The proxy server has an internal communication function for communicating with internal devices, and also has an external communication function for communicating with external devices. At the same time, the internal devices can also access the external devices through the proxy server, wherein the internal devices refer to electronic devices, servers, clients and / or terminals in the same network environment as the proxy server, and the external devices are in different network environments from the internal devices, and the internal devices cannot directly access the external devices. In a possible application scenario, the internal devices and the proxy server 1 are in an isolated production environment 1 (network environment 1), and the external devices are in an isolated production environment 2 (network environment 2). The network environment 1 and the network environment 2 are isolated and can only communicate within the network environment, and cannot communicate with the external network environment. That is to say, each device in the network environment 1 cannot directly communicate with each device in the network environment 2, but each device in the network environment 1 can communicate with each device in the network environment 2 through the proxy server 1. Using the widely supported SSH protocol, the deployment and configuration process is simple and direct, which greatly reduces the technical threshold and maintenance cost. In addition, it can quickly adapt to the changing network conditions and security requirements, making daily maintenance more flexible and efficient.
[0058] Optionally, configuring the SSH service to SOCKS proxy mode to obtain at least one proxy server may be implemented by the following steps:
[0059] Generate a configuration command, the configuration command including a service identifier and configuration information; send the configuration command to a target SSH service corresponding to the service identifier, so that the target SSH service is configured in SOCKS proxy mode based on the configuration information; wherein the configuration information includes a communication port for running SOCKS on a target original server, a data transmission method, and a currently executable function of the target SSH service, the target original server refers to an original server in the at least one original server where the target SSH service is enabled, and the currently executable function does not include a remote command function.
[0060] It is understandable that in order to configure the SSH service to SOCKS proxy mode, it can be achieved through the generated configuration instructions. In this scenario, the configuration instructions can be understood as SSH commands, wherein the configuration instructions include a service identifier and specific configuration information. The service identifier refers to the identifier of the service to be configured running on the original server. For example, the service identifier is SSH-1, which means that the configuration instruction is to configure the SSH-1 service. It is understandable that there may be multiple SSH services enabled on the original server, and SSH-1 refers to the first SSH service among the multiple SSH services. Subsequently, the configuration instruction is sent to the target SSH service corresponding to the service identifier, so that the target SSH service is configured in SOCKS proxy mode based on the configuration information. Based on the above example, the target SSH service refers to SSH-1.
[0061] The format of the configuration command is: SSH-D <port>-f-C-q-N <user> @ <host>, SSH refers to the configuration of the SSH service, D refers to the communication port running SOCKS on the target original server, the target original server refers to the server with the SSH service enabled, the communication port can be understood as the local port configured for SOCKS on the original server, port refers to the specific local port, f is used to configure the SSH service to run in the background to ensure that the SSH service will not be shut down, C refers to the enabled data transmission method, such as enabling compressed data transmission to improve transmission efficiency, q refers to whether to enable silent mode, silent mode means only printing key log data to reduce system log information, N is used to configure the current executable function of the SSH service, the current executable function refers to the original function that the SSH service can achieve, the current executable function does not include remote commands, that is, the SSH service cannot execute remote commands by itself, and can only be forwarded through the local port configured with the SOCKS proxy. The deployment and configuration of SSH SOCKS proxy on different types of servers are different, and other configuration methods are not limited here.
[0062] Optionally, after configuring the SSH service to SOCKS proxy mode and obtaining at least one proxy server, the method further includes:
[0063] Configure security rules corresponding to the firewall and security group on the at least one proxy server, wherein the security rules include at least one terminal that can configure the at least one proxy server and the communication port accessible to the at least one terminal, and the at least one terminal includes the first client.
[0064] It is understandable that the firewall and security group on the proxy server are configured with security rules corresponding to the security rules, including at least one terminal that can be configured for at least one proxy server and at least one communication port accessible to the terminal, and at least one terminal includes the first client, that is, the whitelist of at least one terminal that can be configured for the proxy server can be set through the security rules to ensure that only the IP of a specific terminal from the whitelist can access the communication port where SOCKS is set, so as to enhance the security of network transmission. At the same time, the technical details of using SSH for data encryption and user authentication are also protected to ensure that only authorized users and services can access external resources through the proxy.
[0065] S102: In response to a proxy configuration request from a first client, determine a target proxy server assigned to the first client from among the at least one proxy server.
[0066] It is understandable that, based on the above S101, when the first client has a need to access an external device, a proxy configuration request is generated to request configuration of a proxy server to communicate with the external device. In response to the proxy configuration request, a target proxy server to be assigned to the first client is selected from at least one proxy server. It is understandable that different clients have different needs and are assigned different proxy servers, and the same client may also be assigned different proxy servers at different stages.
[0067] Optionally, the determining of the target proxy server assigned to the first client in the at least one proxy server may be implemented by the following steps:
[0068] Determine the load requirement of the first client in the proxy configuration request; cluster the at least one proxy server to obtain a proxy cluster; load balance the proxy servers in the proxy cluster according to the load requirement, and determine a target proxy server assigned to the first client.
[0069] It is understandable that at least one proxy server is clustered to obtain a proxy cluster. For example, multiple proxy servers are clustered through Haproxy or Nginx to improve the load capacity and availability of the system, wherein Haproxy is a free and open source software written in C language, and Nginx (engine x) is a high-performance HTTP (Hypertext Transfer Protocol) and reverse proxy web (World Wide Web) server. Through the proxy cluster, the load balancing of at least one proxy server can be configured to evenly distribute the request load and optimize the resource utilization efficiency. The proxy configuration request includes the identification and load demand of the first client. After determining the load demand, load balancing is performed on at least one proxy server through the proxy cluster, and the target proxy server that meets the load demand is allocated to the first client. By introducing clustered proxy servers, real-time health checks and automatic fault recovery mechanisms, the stability and availability of network proxy services are significantly improved, and the continuity of services can be ensured even when some components fail. In addition, SSH's strong encryption and authentication mechanisms provide strong security for data transmission. Corresponding user authentication and traffic filtering can also be performed in the Haproxy or Nginx part to ensure that only authorized users and services can access external resources through the proxy.
[0070] It is understandable that in order to enhance security and control accuracy, specific authentication and traffic restriction measures can be implemented in Haproxy or Nginx to ensure the legal and efficient use of the proxy server.
[0071] Optionally, after clustering the at least one proxy server to obtain a proxy cluster, the method further includes:
[0072] A failover mechanism is configured for the proxy cluster, wherein the failover mechanism is used to characterize the correspondence between the failure state of the proxy server and the failure processing; working data of each proxy server in the proxy cluster is obtained, and control instructions for each proxy server are generated based on the working data and the failover mechanism; and the control instructions are executed to update the proxy cluster to obtain an updated proxy cluster.
[0073] Understandably, in order to ensure that all proxy servers in the proxy cluster have excellent continuity and stability, Keepalived (exchange software mechanism) and Haproxy are used to configure a highly available proxy cluster, and a virtual IP and a failover mechanism are configured for the proxy cluster. The failover mechanism is used to characterize the correspondence between the fault state of the proxy server and the fault handling, that is, different processing is performed according to the working state of each proxy server, for example, the failed or poorly performing proxy servers are removed. Real-time health checks of proxy server nodes are implemented through Haproxy or Nginx, the working data of the proxy server is obtained, and the current working state of the proxy server is determined based on the working data. Whether the proxy server fails is determined based on the failover mechanism, and the corresponding control instructions are generated when the proxy server fails or does not fail, so as to ensure the continuous availability and performance stability of the service. This mechanism is particularly important for large-scale and mission-critical applications, and can automatically maintain the health status and dynamic load balancing of the proxy cluster.
[0074] Optionally, the above-mentioned generation of control instructions for each proxy server based on the working data and the failover mechanism can be specifically implemented through the following steps:
[0075] For each proxy server, when it is determined according to the working data that each proxy server is in a healthy state, a first instruction is generated, wherein the first instruction refers to an instruction for controlling each proxy server to perform load balancing; or, when it is determined according to the working data that each proxy server is in an overload state, a second instruction is generated, wherein the second instruction refers to an instruction for controlling each proxy server to exit load balancing, wherein the overload state refers to that the load of each proxy server exceeds the rated capacity; or, when it is determined according to the working data that each proxy server is in a failed state, a third instruction is generated, wherein the third instruction refers to an instruction for controlling each proxy server to exit the proxy cluster, wherein the failed state refers to that a network failure occurs in each proxy server; wherein the control instruction includes the first instruction, the second instruction and the third instruction.
[0076] It is understandable that a health check is performed on each proxy server in the proxy cluster, and after the test result is obtained, different control instructions are generated according to the test result. Specifically, when it is determined according to the working data that each proxy server is in a healthy state, that is, the proxy server has not failed and is in a normal working state, a first instruction is generated in this case, and the first instruction refers to an instruction to control the proxy server to perform load balancing, that is, the proxy server in a healthy state participates in load balancing and can be allocated to the first client; or, when it is determined according to the working data that each proxy server is in an overloaded state, that is, the load resources of the proxy server are insufficient and cannot be allocated to the first client. , in this case, a second instruction is generated, and the second instruction refers to an instruction to control the proxy server to exit load balancing, that is, the proxy cluster does not consider the proxy server when performing load balancing, and the overload state can be understood as the load of the proxy server exceeding the rated capacity; or, when the proxy server is determined to be in an invalid state based on the working data, that is, the proxy server cannot be connected or is disconnected, a third instruction is generated in this case, and the third instruction refers to an instruction to control each proxy server to exit the proxy cluster, that is, to remove the invalid proxy server from the proxy cluster, and the invalid state refers to a network failure in the proxy server; wherein, the control instruction includes the first instruction, the second instruction and the third instruction. It is understandable that other possible control instructions can be further divided according to the working status of the proxy server, such as determining the priority of the proxy server according to the working status, considering the priority of each proxy server during load balancing, etc. Other possible control instructions are not limited here.
[0077] For example, see Figure 2 , Figure 2 The schematic diagram of the structure of the proxy cluster provided in the embodiment of the present disclosure, the proxy cluster is configured with TCP / IP (Transmission Control Protocol / Internet Protocol), TCP / IP refers to a protocol suite that can realize information transmission between multiple different networks. The proxy cluster includes multiple proxy servers, a first module for load balancing, and multiple second modules for configuring a failover mechanism, wherein the proxy server is denoted as SOCKS5PROXY, SOCKS5 is a transparent PROXY protocol, such as Figure 2 The proxy cluster shown includes 3 proxy servers, and the SSH service enabled by the server is forwarded through dynamic ports. The first module is used to achieve load balancing of multiple proxy servers. The second module uses Keepalived and Haproxy to configure a highly available proxy cluster, and configures a high availability strategy and real-time monitoring system through Haproxy or Nginx. The automatic switching and fault response mechanism of the proxy server can protect the uninterrupted operation of network services.
[0078] Optionally, performing load balancing on the proxy servers in the proxy cluster according to the load demand and determining the target proxy server allocated to the first client may be specifically implemented through the following steps:
[0079] Load balancing is performed on the proxy servers in the updated proxy cluster according to the load demand, and a target proxy server assigned to the first client is determined.
[0080] It is understandable that after health detection is performed on each proxy server in the proxy cluster and control instructions generated according to the detection results are executed, an updated proxy cluster is obtained. Subsequently, a target proxy server that meets the load requirement is determined in the updated proxy cluster.
[0081] S103: Send the network communication information of the target proxy server to the first client, so that the first client accesses the second client by using the target proxy server based on the network communication information.
[0082] The first client and the second client are in different network environments.
[0083] It can be understood that based on the above S102, the network communication information of the target proxy server is sent to the first client, and the first client will be configured based on the network communication information so that it can locate the target geographic server based on the network communication information, and access the second client through the target proxy server, wherein the first client and the second client are in different network environments, and the second client can be configured with an external network access mode and / or an internal network access mode.
[0084] Optionally, the first client refers to at least one of a Kubernetes cluster, a container for mirroring, and a Java application; the network communication information includes the communication address of the target proxy server and the communication port of the target proxy server running SOCKS; the Kubernetes cluster is used to set the communication address and the communication port as environment variables in the deployment description file of the node; the container is used to set the communication address and the communication port as environment variables in a text file for building an image; and the Java application is used to set the communication address and the communication port through Java virtual machine startup parameters.
[0085] It is understandable that the first client can be at least one of a Kubernetes cluster, a container, a Java virtual machine, and a Java HTTP client, and the network communication information includes the communication address (IP) of the target proxy server and the communication port (port) of the target proxy server running SOCKS. Different types of clients configure the proxy in different ways according to the network communication information. Specifically, in the Kubernetes cluster, the proxy is configured for each node (Pod) therein through environment variables or ConfigMaps, and multiple proxy servers can be assigned to the Kubernetes cluster. Further, each node can also be configured with different proxy servers. Add environment variables HTTP_PROXY and HTTPS_PROXY in the deployment description file of the Pod to specify the address and port of the target proxy server, so that all outbound HTTP / HTTPS requests in the Pod will be made through the SSH SOCKS proxy. The present application provides a multi-level proxy configuration, which provides a fine-grained proxy configuration method for the system, container, virtual machine, and application levels, allowing users to flexibly configure their proxy settings according to specific network and security requirements. The support of this multi-level proxy configuration ensures that data at any level can be transmitted through a secure channel.
[0086] In one implementation, when building an image container, set environment variables in Dockerfile to ensure that the proxy server is automatically configured when the container starts. Dockerfile is a text file used to build an image. The text content contains instructions and instructions required to build the image. You can add ENV HTTP_PROXY<proxy_server> and ENV HTTPS_PROXY<proxy_server> To implement in Dockerfile, each container will inherit these proxy settings when it starts. ENV refers to the environment variable, and the communication port and communication address are set through proxy_server. For Java applications running in Kubernetes clusters, the proxy settings are specified through the JVM (Java Virtual Machine) startup parameters, such as Dhttp.proxyHost=<proxy_host> and Dhttp.proxyPort=<proxy_port> , proxy_host refers to the communication address, proxy_port refers to the communication port. Setting parameters ensures that the Java virtual machine automatically uses the SSH SOCKS proxy when performing any HTTP / HTTPS operation to ensure secure data transmission.
[0087] In one implementation, at the Java application level, a proxy server can also be configured separately for an HTTP client, that is, a proxy can be configured separately for an HTTP client that requires specific network access rules. For example, when using Apache HttpClient (client programming toolkit), a specific HttpClient instance can be created and configured to use a specific proxy server. This can usually be done by configuring HttpHost to the communication address and communication port of the proxy server, and then applying it to the client's connection manager.
[0088] A possible application scenario requires secure access to a resource library stored on the public Internet. In this case, an SSH SOCKS proxy can be quickly configured on a central server, and the central processor can be used as a proxy server. Other servers can start to securely access the required resources through the proxy server without complex network configuration. This method not only saves time, but also ensures the security of data transmission through SSH encryption. Another possible application scenario is that the IT budget is limited and the built-in SSH service can be used to implement the network proxy function, which can significantly reduce costs. Existing servers and SSH configurations can be used as proxy servers without investing in specialized network security hardware or software, achieving economical and efficient data access and protection, which not only reduces the financial burden on the enterprise, but also simplifies the implementation process of network security. In the above scenario, the present application can achieve rapid deployment and security assurance.
[0089] It can be understood that this application can implement service access control in a multi-cloud environment, can be used to connect multiple cloud environments and local Kubernetes clusters, manage all outbound traffic through a unified proxy service, simplify security configuration, and enhance data protection and compliance.
[0090] Understandably, for enterprises that require highly reliable network services, the high-availability configuration achieved through clustered SSH SOCKS proxy servers combined with Haproxy and Keepalived can ensure that even if some nodes fail, the availability of the overall service will not be affected. This high availability and large-scale deployment is especially important for industries such as finance and e-commerce that have strict requirements on network stability and response speed.
[0091] Understandably, in business operations that must comply with data protection regulations such as GDPR (General Data Protection Regulation), proxy servers can serve as key nodes for data filtering and cleaning to ensure that sensitive data is processed within a compliance framework.
[0092] Understandably, the encryption and authentication features of SSH SOCKS proxy complement the strictness of data protection regulations and enable security and supervision. As more and more enterprises adopt containerization and cloud native technologies, SSH SOCKS proxy can provide seamless and secure access to these architectures. With the widespread use of IoT devices, SSH-based proxy technology can help distributed devices obtain stable and secure network channels.
[0093] The network access method provided by the present disclosure has load balancing and high availability: in a cloud environment, the SSHSOCKS proxy service is clustered, and load balancing is achieved through Haproxy or Nginx, and high availability configuration is achieved in combination with Keepalived, thereby improving the system's fault tolerance to faults and ensuring the continuous availability of the service. It has real-time monitoring and automatic fault recovery: using the advanced monitoring function of Haproxy or Nginx, real-time service health checks and automatic health management and fault recovery are implemented. This automated operation and maintenance method not only improves the stability of the system, but also reduces the need for manual intervention, making system management more efficient. It is capable of key management: managing and distributing SSH keys in a large cloud environment may involve complex security policies and audit requirements. Using the cloud platform's confidentiality management or centralized key management service can simplify key distribution. It is capable of performance optimization: in a distributed environment, network delay and jitter may affect proxy performance. Using traffic compression and caching mechanisms can optimize proxy performance, and real-time traffic is used for analysis to reduce network delays.
[0094] Figure 3 The network access device provided by the embodiment of the present disclosure can execute the processing flow provided by the network access method embodiment, such as Figure 3 As shown, the apparatus 300 includes a configuration unit 301, a determination unit 302 and a sending unit, wherein:
[0095] The configuration unit 301 is used to enable the SSH service on at least one original server and configure the SSH service to a SOCKS proxy mode to obtain at least one proxy server;
[0096] A determining unit 302 is configured to determine, in response to a proxy configuration request of a first client, a target proxy server assigned to the first client from among the at least one proxy server;
[0097] The sending unit 303 is used to send the network communication information of the target proxy server to the first client, so that the first client uses the target proxy server to access the second client based on the network communication information, wherein the first client and the second client are in different network environments.
[0098] Optionally, the configuration unit 301 is used to:
[0099] Generate a configuration command, wherein the configuration command includes a service identifier and configuration information;
[0100] Sending the configuration command to a target SSH service corresponding to the service identifier, so that the target SSH service performs configuration of a SOCKS proxy mode based on the configuration information;
[0101] Among them, the configuration information includes the communication port, data transmission method and current executable functions of the target SSH service running on the target original server. The target original server refers to the original server in the at least one original server where the target SSH service is enabled, and the current executable functions do not include remote command functions.
[0102] Optionally, the device 300 is used for:
[0103] Configure security rules corresponding to the firewall and security group on the at least one proxy server, wherein the security rules include at least one terminal that can configure the at least one proxy server and the communication port accessible to the at least one terminal, and the at least one terminal includes the first client.
[0104] Optionally, the determining unit 302 is configured to:
[0105] Determining a load requirement of the first client in the proxy configuration request;
[0106] performing clustering processing on the at least one proxy server to obtain a proxy cluster;
[0107] Load balancing is performed on the proxy servers in the proxy cluster according to the load demand, and a target proxy server allocated to the first client is determined.
[0108] Optionally, the device 300 is used for:
[0109] Configuring a failover mechanism for the proxy cluster, wherein the failover mechanism is used to characterize the corresponding relationship between the failure state of the proxy server and the failure processing;
[0110] Acquire working data of each proxy server in the proxy cluster, and generate control instructions for each proxy server based on the working data and the failover mechanism;
[0111] Executing the control instruction to update the proxy cluster to obtain an updated proxy cluster;
[0112] The step of performing load balancing on the proxy servers in the proxy cluster according to the load demand and determining a target proxy server assigned to the first client includes:
[0113] Load balancing is performed on the proxy servers in the updated proxy cluster according to the load demand, and a target proxy server assigned to the first client is determined.
[0114] Optionally, the device 300 is used for:
[0115] For each proxy server, when it is determined according to the working data that each proxy server is in a healthy state, a first instruction is generated, where the first instruction is an instruction for controlling each proxy server to perform load balancing; or,
[0116] In the case where it is determined according to the working data that each proxy server is in an overload state, generating a second instruction, wherein the second instruction is an instruction for controlling each proxy server to exit load balancing, and the overload state means that the load of each proxy server exceeds the rated capacity; or
[0117] In the case where it is determined according to the working data that each proxy server is in a failed state, generating a third instruction, wherein the third instruction is an instruction for controlling each proxy server to exit the proxy cluster, and the failed state is that a network failure occurs in each proxy server;
[0118] The control instruction includes the first instruction, the second instruction and the third instruction.
[0119] Optionally, the first client in the device 300 refers to at least one of a Kubernetes cluster, a container for mirroring, and a Java application;
[0120] The network communication information includes the communication address of the target proxy server and the communication port of the target proxy server running SOCKS;
[0121] The Kubernetes cluster is used to set the communication address and the communication port as environment variables in the deployment description file of the node;
[0122] The container is used to set the communication address and the communication port as environment variables in a text file for building an image;
[0123] The Java application is used to set the communication address and the communication port through Java virtual machine startup parameters.
[0124] Figure 3 The network access device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0125] Figure 4 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 4 , which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present disclosure. The electronic device 400 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0126] like Figure 4 As shown, the electronic device 400 may include a processing device 401 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 to a random access memory (RAM) 403 to implement the network access method of the embodiment described in the present disclosure. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0127] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0128] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the network access method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0129] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0130] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0131] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0132] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0133] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0134] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0135] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0136] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0137] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0138] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or gateway that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or gateway. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or gateway that includes the elements.
[0139] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.< / host> < / user> < / port>
Claims
1. A network access method, characterized in that: The method comprises: Enabling an SSH service on at least one original server and configuring the SSH service to a SOCKS proxy mode to obtain at least one proxy server; In response to a proxy configuration request of a first client, determining a target proxy server assigned to the first client among the at least one proxy server; The network communication information of the target proxy server is sent to the first client, so that the first client uses the target proxy server to access the second client based on the network communication information, wherein the first client and the second client are in different network environments.
2. The method according to claim 1, characterized in that The step of configuring the SSH service to a SOCKS proxy mode to obtain at least one proxy server includes: Generate a configuration command, wherein the configuration command includes a service identifier and configuration information; Sending the configuration command to a target SSH service corresponding to the service identifier, so that the target SSH service performs configuration of a SOCKS proxy mode based on the configuration information; Among them, the configuration information includes the communication port, data transmission method and current executable functions of the target SSH service running on the target original server. The target original server refers to the original server in the at least one original server where the target SSH service is enabled, and the current executable functions do not include remote command functions.
3. The method according to claim 2, characterized in that After configuring the SSH service to SOCKS proxy mode and obtaining at least one proxy server, the method further includes: Configure security rules corresponding to the firewall and security group on the at least one proxy server, wherein the security rules include at least one terminal that can configure the at least one proxy server and the communication port accessible to the at least one terminal, and the at least one terminal includes the first client.
4. The method according to claim 1, characterized in that: The step of determining a target proxy server assigned to the first client in the at least one proxy server comprises: Determining a load requirement of the first client in the proxy configuration request; performing clustering processing on the at least one proxy server to obtain a proxy cluster; Load balancing is performed on the proxy servers in the proxy cluster according to the load demand, and a target proxy server allocated to the first client is determined.
5. The method according to claim 4, characterized in that After clustering the at least one proxy server to obtain a proxy cluster, the method further includes: Configuring a failover mechanism for the proxy cluster, wherein the failover mechanism is used to characterize the corresponding relationship between the failure state of the proxy server and the failure processing; Acquire working data of each proxy server in the proxy cluster, and generate control instructions for each proxy server based on the working data and the failover mechanism; Executing the control instruction to update the proxy cluster to obtain an updated proxy cluster; The step of performing load balancing on the proxy servers in the proxy cluster according to the load demand and determining a target proxy server assigned to the first client includes: Load balancing is performed on the proxy servers in the updated proxy cluster according to the load demand, and a target proxy server assigned to the first client is determined.
6. The method according to claim 5, characterized in that The generating of control instructions for each proxy server based on the working data and the failover mechanism includes: For each proxy server, when it is determined according to the working data that each proxy server is in a healthy state, a first instruction is generated, where the first instruction is an instruction for controlling each proxy server to perform load balancing; or, In the case where it is determined according to the working data that each proxy server is in an overload state, generating a second instruction, wherein the second instruction is an instruction for controlling each proxy server to exit load balancing, and the overload state means that the load of each proxy server exceeds the rated capacity; or In the case where it is determined according to the working data that each proxy server is in a failed state, generating a third instruction, wherein the third instruction is an instruction for controlling each proxy server to exit the proxy cluster, and the failed state is that a network failure occurs in each proxy server; The control instruction includes the first instruction, the second instruction and the third instruction.
7. The method according to claim 1, characterized in that The first client refers to at least one of a Kubernetes cluster, a container for mirroring, and a Java application; The network communication information includes the communication address of the target proxy server and the communication port of the target proxy server running SOCKS; The Kubernetes cluster is used to set the communication address and the communication port as environment variables in the deployment description file of the node; The container is used to set the communication address and the communication port as environment variables in a text file for building an image; The Java application is used to set the communication address and the communication port through Java virtual machine startup parameters.
8. A network access device, characterized in that: The device comprises: A configuration unit, configured to enable an SSH service on at least one original server and configure the SSH service to a SOCKS proxy mode to obtain at least one proxy server; a determining unit, configured to determine, in response to a proxy configuration request of a first client, a target proxy server assigned to the first client from among the at least one proxy server; The sending unit is used to send the network communication information of the target proxy server to the first client, so that the first client uses the target proxy server to access the second client based on the network communication information, wherein the first client and the second client are in different network environments.
9. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the network access method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the network access method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Access request processing method and device, electronic equipment and readable medium
CN119854026A
Application access security control method and system and computer readable storage medium
CN121151142A
