zl程序教程

您现在的位置是:首页 >  系统

当前栏目

为Windows终端配置proxy

Windows配置 终端 Proxy
2023-09-14 09:15:54 时间

为Windows终端配置proxy–适用于cmd

参考: https://github.com/shadowsocks/shadowsocks-windows/issues/1489

# 配置带验证的http proxy
set HTTP_PROXY=http://user:password@proxy.domain.com:port

# 不带验证的
set http_proxy=http://127.0.0.1:1080
set https_proxy=http://127.0.0.1:1080

# 如果设置了验证
set HTTP_PROXY=http://proxy.com:port
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=password

set HTTPS_PROXY=http://proxy.com:port
set HTTPS_PROXY_USER=username
set HTTPS_PROXY_PASS=password

# 清除proxy设置
set http_proxy=
set https_proxy=

为Windows终端配置proxy–适用于PowerShell

参考: https://github.com/shadowsocks/shadowsocks-windows/issues/1489
https://gist.github.com/famousgarkin/c5138b1e13ac41920d22


检查是否已有配置文件

# 检查是否已有配置文件
Test-path $profile

在这里插入图片描述


如果为false手动创建profile

# 手动创建profile
New-item –type file –force $profile

# 使用记事本打开profile文件
notepad $profile

proxy配置正文

PowerShell不支持socks5

# 方案1: http_proxy
$env:http_proxy="http://127.0.0.1:1080"
$env:https_proxy="http://127.0.0.1:1080"

## 带http认证的
$env:http_proxy="user:password@proxy.domain.com:port"
$env:https_proxy="user:password@proxy.domain.com:port"

# 方案2: ALL_PROXY
$env:ALL_PROXY="socks5://127.0.0.1:1080"

powershell配置变量常见用法

https://www.cnblogs.com/liuyt/p/5677781.html
https://www.i4k.xyz/article/luoyooi/102990113

# Powershell设置环境变量

# 查看所有环境变量  
ls env:

# 搜索环境变量   
ls env:NODE*

# 查看单个环境变量 
$env:NODE_ENV

# 添加/更新环境变量 
$env:NODE_ENV=development

# 删除环境变量        
del evn:NODE_ENV