The remote server sets the proxy to share the local network - to solve the problem that the intranet environment cannot be git, pip, etc.

Some servers are not connected to the external network, resulting in the inability to use git, unable to install packages, etc. The offline installation is too cumbersome. This article uses Clash to share the local win computer network to the remote server, which is only used for servers (linux intranet) and local computers (win can be connected to the external network), and the local area and the server are in the same local area network (such as the campus network)

Proceed as follows:

  1. On the local computer Clash, enable the Allow LAN function, and the port uses 7890 by default

  1. The local computer can check its own ip address, you can use the ipconfig command, the following ipv4 address is 222.20.75.93

  1. Due to the firewall of some computers, the proxy of the 7890 may fail. It is recommended to add a port to the inbound rules of the computer firewall. The method is as follows:

Windows Security Center -> Firewall and Network Protection -> Advanced Settings -> Inbound Rules -> New Rule

You only need to open TCP, select a specific local port 7890 (the port number is based on the port on the clash software), and name it as you like

At this point, the machine can be used as a proxy, and the next step is how to use the local proxy on the linux server

  1. The server uses a proxy for various commands, and the local address plus port (here is 222.20.75.93:7890) is enough.

  • (1) For git setting proxy, pay attention to modify the proxy address:

# 设置代理
git config --global http.proxy http://222.20.75.93:7890
git config --global https.proxy https://222.20.75.93:7890
# 重置取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
  • (2) pip command: add --proxy=proxy IP: port at the end of the pip command

pip install robotframework --proxy=222.20.75.93:7890
  • (3) Other system commands such as apt can be used to set the proxy method to search directly, or modify the server environment variables to add a global proxy.

Guess you like

Origin blog.csdn.net/weixin_44576482/article/details/128667675