# 设置apt通过代理安装软件

在Ubuntu上安装软件时，如果需要使用代理服务器，可以在`/etc/apt/apt.conf`中设置，添加如下行：

```
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
```

如果代理服务器需要密码和账号登陆，则将

```
"http://yourproxyaddress:proxyport";
```

修改成

```
"http://username:password@yourproxyaddress:proxyport";
```

> 共享上网的HTTP代理可以采用[Polipo:小巧的web代理服务器](https://github.com/huataihuang/cloud-atlas-draft/tree/b8ddb8068dccea09024fc5bfd3bfc53b7dc0e5c2/service/proxy/polipo/README.md)

## proxy.conf

现在比较新的Ubuntu版本，有关apt的配置都存放在 `/etc/apt/apt.conf.d` 目录下，所以建议将代理配置设置为 `/etc/apt/apt.conf.d/proxy.conf`

```
Acquire::http::Proxy "http://user:password@proxy.server:port/";
Acquire::https::Proxy "http://user:password@proxy.server:port/";
```

## 参考

* [Configure proxy for APT?](https://askubuntu.com/questions/257290/configure-proxy-for-apt)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/os/linux/ubuntu/install/apt_proxy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
