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

推荐订阅源

博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
T
Tailwind CSS Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
N
News and Events Feed by Topic
月光博客
月光博客
TaoSecurity Blog
TaoSecurity Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
N
News | PayPal Newsroom
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Privacy & Cybersecurity Law Blog
GbyAI
GbyAI
K
Kaspersky official blog
WordPress大学
WordPress大学
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
W
WeLiveSecurity
Jina AI
Jina AI
The Cloudflare Blog
Project Zero
Project Zero
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
L
LangChain Blog
Forbes - Security
Forbes - Security
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
博客园 - 【当耐特】
H
Heimdal Security Blog
A
About on SuperTechFans
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
L
LINUX DO - 最新话题
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
Intezer
Martin Fowler
Martin Fowler
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint

披萨盒的赛博日志

谈谈工作了半年的感受 使用策略模式重构复杂业务分支 像 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

披萨盒

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

个人主页