侧边栏壁纸
博主头像
博主等级

秋风清,秋月明,落叶聚还散,寒鸦息复惊,相思相见知何日,此时此夜难为情!

  • 累计撰写 22 篇文章
  • 累计创建 33 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录
git

常用代理的设置与取消

尘
2024-01-23 / 0 评论 / 0 点赞 / 637 阅读 / 6199 字
温馨提示:
本文最后更新于 2024-08-29,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

各种代理的设置和取消

Git设置与取消代理

设置代理

git config --global http.proxy http://127.0.0.1:10809
git config --global https.proxy http://127.0.0.1:10809

取消代理

git config --global --unset http.proxy
git config --global --unset https.proxy

curl 使用代理

curl 命令行中设置代理,可以使用 -x--proxy 选项。以下是如何使用 curl 设置 HTTP 或 HTTPS 代理的示例:

设置 HTTP 代理

curl -x http://proxy-server:port http://example.com

设置 HTTPS 代理

curl -x https://proxy-server:port https://example.com

设置带用户名和密码的代理

如果代理服务器需要身份验证,可以通过以下方式设置用户名和密码:

curl -x http://username:password@proxy-server:port http://example.com

设置 SOCKS 代理

curl 也支持 SOCKS 代理,例如 SOCKS4 和 SOCKS5:

curl --socks5 proxy-server:port http://example.com

或使用带用户名和密码的 SOCKS 代理:

curl --socks5 username:password@proxy-server:port http://example.com

跳过代理

如果你想为特定的 URL 跳过代理,可以使用 --noproxy 选项:

curl --noproxy example.com http://example.com

这些命令允许你通过代理服务器访问目标 URL,根据需要设置代理类型和身份验证信息。

Scoop的代理设置于取消

官方文档说明:https://github.com/ScoopInstaller/Scoop/wiki/Using-Scoop-behind-a-proxy

Once Scoop is installed, you can use scoop config to configure your proxy. Here’s an excerpt from scoop help config:


scoop config proxy [username:password@]host:port

By default, Scoop will use the proxy settings from Internet Options, but with anonymous authentication.

  • To use the credentials for the current logged-in user, use currentuser in place of username:password
  • To use the system proxy settings configured in Internet Options, use default in place of host:port
  • An empty or unset value for proxy is equivalent to default (with no username or password)
  • To bypass the system proxy and connect directly, use none (with no username or password)

设置代理

scoop config proxy localhost:10809

要删除这个设置的话就直接

scoop config rm proxy

apt-get代理设置

1. 环境变量方法

设置环境变量,下面是临时设置

export http_proxy=http://127.0.0.1:8000
sudo apt-get update

要取消通过 export http_proxy=http://127.0.0.1:8000 设置的 HTTP 代理,您可以使用以下两种方法之一:

方法 1:清除环境变量

您可以使用 unset 命令清除 http_proxy 环境变量。这将使代理设置临时失效,直到再次设置为止。

Bash

unset http_proxy

方法 2:修改配置文件

如果您想永久取消代理设置,则需要修改相应的配置文件。具体的文件取决于您的操作系统:

  • Linux/macOS:
    • 对于用户范围的设置,请编辑 ~/.bashrc~/.zshrc 文件。
    • 对于系统范围的设置,请编辑 /etc/profile/etc/bashrc 文件。

在文件中,找到以下行并删除或注释掉:

export http_proxy=http://127.0.0.1:8000

保存文件后,重新启动终端或重新登录计算机以使更改生效。

2. 设置apt-get的配置

修改/etc/apt/apt.conf(或者/etc/envrionment),增加

Acquire::http::proxy "http://127.0.0.1:8000/";
Acquire::ftp::proxy "ftp://127.0.0.1:8000/";
Acquire::https::proxy "https://127.0.0.1:8000/";

3. 在命令行临时带入

这是我最喜欢的方法,毕竟apt不是时时刻刻都用的
在命令行后面增加-o选项

sudo apt-get -o Acquire::http::proxy="http://127.0.0.1:8000/" update

NVM

安装

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

如果需要使用代理可以使用下面的命令:

curl -x 'http://127.0.0.1:7897' -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

或者使用wget

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

同样可以使用代理:

wget -e 'https_proxy=http://192.168.56.1:7897' -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

安装Node使用镜像

使用镜像下载Node的二进制, set $NVM_NODEJS_ORG_MIRROR:

export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
nvm install node

NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/ nvm install 4.2

使用镜像下载 io.js , set $NVM_IOJS_ORG_MIRROR:

export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
nvm install iojs-v1.0.3

NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3
0

评论区