Terminal设置代理

0x01 Terminal代理设置

给终端terminal设置代理

1
2
3
4
5
$ vim ~/.zshrc
## proxy
export http_proxy=http://127.0.0.1:8001
export https_proxy=$http_proxy
$ source ~/.zshrc

0x02 AndroidStudio代理设置

Android Studio 的代理设置

Perference --> Appearance & Behavior --> System Settings --> Http Proxy

20230517195623

0x03 Gradle代理设置

gradle代理可以配置在:

  1. 环境变量GRADLE_USER_HOME指定的gradle系统目录默认路径\Users\Xxx\.gradle\gradle.properties
  2. 项目根目录gradle.properties

前者优先级更高。

1
2
3
4
5
6
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
systemProp.socks.proxyHost=127.0.0.1
systemProp.socks.proxyPort=1080

0x04 配置代理用户名和密码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Project-wide Gradle settings.
...
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain

systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=443
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.auth.ntlm.domain=domain
...

0x05 过滤代理

对于国内的仓库可以不走代理,还有部分内网地址也可以不走代理

1
2
3
systemProp.http.nonProxyHosts=developer.huawei.com|maven.aliyun.com|192.168.*
systemProp.https.nonProxyHosts=developer.huawei.com|maven.aliyun.com|192.168.*
systemProp.socks.nonProxyHosts=developer.huawei.com|maven.aliyun.com|192.168.*

0x06 修改gradle.properties配置

1
org.gradle.jvmargs=-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=10808
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×