Files
nexus/wiki/sources/Ubuntu-Server科学上网配置指南.md
weishen e62797a33a Batch 9: Obsidian插件/AI开源平替/Coze培训/TK面单/Ubuntu科学上网
- Sources: 5个新文档
- Concepts: ProxyChains, SOCKS5代理, Docker Daemon代理
- Index: 更新至 Batch 9
- 累计 sources: 108/182
2026-04-16 06:36:36 +08:00

52 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Ubuntu Server 科学上网配置指南"
type: source
tags: [Ubuntu, 科学上网, V2Ray, ProxyChains, Docker, 代理]
date: 2025-12-29
---
## Source File
- [[raw/Home Office/Ubuntu Server科学上网.md]]
## Summary
- 核心主题Ubuntu Server 环境下配置科学上网的完整方案
- 问题域:终端命令/Git/Docker 守护进程/容器内应用如何走代理
- 方法/机制分层代理架构——ProxyChains临时命令、Git 全局配置Git 专设、systemd Docker 代理(镜像拉取)、~/.docker/config.json容器内应用
- 结论/价值不同场景用不同方案不可混用Daemon 层面走 systemd用户层面走环境变量
## Key Claims
### ProxyChains终端命令级
- 修改 `/etc/proxychains4.conf` 添加 `socks5 127.0.0.1 10808`
- 任何命令前加 `proxychains4` 前缀即可穿代理:`proxychains4 curl https://google.com`
### Git 代理配置
- 设置全局:`git config --global http.proxy 'socks5://127.0.0.1:10808'`
- Docker 守护进程不走用户环境变量,必须通过 systemd 配置
### Docker Pull 代理Daemon 级)
- 创建 `/etc/systemd/system/docker.service.d/http-proxy.conf`
- 添加 `HTTP_PROXY/HTTPS_PROXY/NO_PROXY` 环境变量
- 必须执行 `systemctl daemon-reload && systemctl restart docker`
- 验证:`docker info | grep -i proxy`
### Docker 容器内代理(应用级)
- 方案 A推荐 17.07+`~/.docker/config.json` 添加 `proxies.default`
- 方案 Bdocker-compose.yml 环境变量 `ALL_PROXY=socks5://172.24.0.1:10808`
- 容器内获取宿主机 IP`docker exec <container> ip route | awk '/default/ {print $3}'`
## Key Concepts
- [[ProxyChains]]:终端命令强制走 SOCKS5 代理工具
- [[SOCKS5 代理]]:支持本地 DNS 解析socks5h://)的代理协议
- [[Docker Daemon 代理]]Docker 守护进程级代理配置,通过 systemd 环境变量注入
- [[Docker 容器内代理]]:容器应用级代理,通过 ~/.docker/config.json 或 docker-compose environment
## Key Entities
- [[V2RayN]]SOCKS5/HTTP 代理客户端(运行在宿主机)
- [[Ubuntu Server]]Linux 服务器操作系统
## Connections
- [[V2RayN]] ← 提供代理 ← [[SOCKS5 代理]]
- [[ProxyChains]] ← 转发至 ← [[SOCKS5 代理]]
- [[Docker Daemon 代理]] ← 配置 ← [[Ubuntu Server]]