惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News | PayPal Newsroom
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog
S
SegmentFault 最新的问题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Project Zero
Project Zero
P
Privacy & Cybersecurity Law Blog
V
Vulnerabilities – Threatpost
博客园 - 三生石上(FineUI控件)
Recorded Future
Recorded Future
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
T
Tor Project blog
T
The Exploit Database - CXSecurity.com
Schneier on Security
Schneier on Security
H
Help Net Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
M
MIT News - Artificial intelligence
W
WeLiveSecurity
P
Proofpoint News Feed
A
About on SuperTechFans
S
Securelist
I
InfoQ
G
Google Developers Blog
博客园 - 司徒正美
博客园 - 叶小钗
Latest news
Latest news
F
Fortinet All Blogs
G
GRAHAM CLULEY
腾讯CDC
Jina AI
Jina AI
S
Schneier on Security
I
Intezer
V
Visual Studio Blog
美团技术团队
V2EX - 技术
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
罗磊的独立博客
Y
Y Combinator Blog

披萨盒的赛博日志

谈谈工作了半年的感受 使用策略模式重构复杂业务分支 像 systemd 一样管理 MacOS 后台常驻任务 以ORM看封装的边界 Git Merge VS Git Rebase: 如何优雅地合并分支? 修改Linux内核模块以支持WG OpenLDAP折腾日记 非特权模式容器 ssh 登录问题 白嫖 Aseprite 像素绘图软件 MongoDB 增删改查 Python数据分析工具包-Numpy 解决 CLion 中文乱码问题 搭建 RLCraft 服务器 SpringBoot读取配置文件 Centos 配置 LNMP 环境 部署项目时遇到的坑 浅谈 xhr 请求跨域问题 JavaScript 学习笔记 Eclipse配置Web开发环境 Vue2 基本知识 Ribbon 简单使用 Nacos 简单使用 Spring Cloud Alibaba 环境搭建 什么是RSS?什么是Feed?它们有什么关系? Docker基本使用 TensorFlow启用GPU加速 如何进行内网穿透 Hello World! Git基本使用 Butterfly常用标签外挂
在 Linux 开发环境中使用网络代理
披萨盒 · 2024-10-17 · via 披萨盒的赛博日志

默认现在本机已经安装好了代理软件客户端,暴露出的 http 端口为7890,socks5 端口为7891。

因为此域名是接受过国内备案的,不易多说 🤫

Linux Shell使用网络代理

当前终端使用代理

设置代理:export http_proxy=http://127.0.0.1:7890 && export https_proxy=http://127.0.0.1:7890

取消代理:unset http_proxy && unset https_proxy

全局使用代理

如果是root用户,修改/etc/profile。如果是普通用户,修改~/.bashrc。在文件最后添加如下内容

1
2
3

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891

然后刷新配置文件:source /etc/profile或者source ~/.bashrc

Docker使用网络代理

Docker本身使用代理(如docker pull)

1
mkdir -p /etc/systemd/system/docker.service.d

添加代理

1
vim /etc/systemd/system/docker.service.d/http-proxy.conf
1
2
3
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"

重启docker

1
2
systemctl daemon-reload
systemctl restart docker

Docker容器使用代理

  1. 如果是在Dockerfile中,则直接设置
1
2
ENV http_proxy='http://127.0.0.1:7890'
ENV https_proxy='http://127.0.0.1:7890'
  1. 如果是在docker run时想添加代理,则使用-e进行添加,如
1
docker run -d -e http_proxy=http://127.0.0.1:7890 -e https_proxy=http://127.0.0.1:7890 image

Git使用网络代理

如果已经用上述 “Linux Shell使用网络代理” 配置过了,则 git 会默认使用上面配置的。如果只想单独给 git 配置代理,参考下面的方法。

  1. 方法一:编辑文件

编辑文件~/.gitconfig

1
vim ~/.gitconfig
1
2
3
4
[https]
proxy = http://127.0.0.1:7890
[http]
proxy = http://127.0.0.1:7890
  1. 方法二:命令行
1
2
3
4
5
6
7
8
9
10
11
12
13
14

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

git config --global http.http://github.com.proxy socks5://127.0.0.1:7891
git config --global https.https://github.com.proxy socks5://127.0.0.1:7891


git config --global http.http://github.com.proxy http://127.0.0.1:7890
git config --global https.https://github.com.proxy http://127.0.0.1:7890


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

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-ND 4.0 许可协议。转载请注明来源 披萨盒的赛博日志


avatar

披萨盒

反正身体这么好,今天继续笑下去吧

个人主页