menu
Thinking Null
phonelink
more_vert
chevron_right
首页
»
Ubuncrash
,
Linux
» 正文
为Snapd设置代理
2020-10-05 |
Ubuncrash
,
Linux
| 暂无评论 | 114 次阅读 | 250字
一般地,Linux上的一些应用程序会通过读取环境变量http_proxy和https_proxy来应用代理服务器设置,典型的有Chrome。然而,Snap比较特别,它不会从环境变量中上述环境变量中读取代理服务器设置,因此直接使用`export http_proxy=[代理服务器地址]`或`export https_proxy=[代理服务器地址]`是不起作用的。 那么,有何正确的方法? ###方法一:覆盖snapd的现有设置 (推荐) 除了修改environment文件,也可以修改snapd服务的配置文件,在其加入Environment信息。 运行以下命令,打开snapd的配置文件: ``` sudo systemctl edit snapd.service ``` 在打开的文本编辑器中,加入以下语句: ```shell [Service] Environment=http_proxy=http://proxy:port Environment=https_proxy=http://proxy:port ``` 最后重新加载snapd服务: ```shell sudo systemctl daemon-reload sudo systemctl restart snapd.service ``` ###方法二:更改 /etc/environment `/etc/environment`是一个Shell脚本,snapd会读取它,应用其中指定的配置信息。因此,设置代理服务器的正确目标,实际上就是这里。 在/etc/environment中加入: ```shell http_proxy=http: //[服务器地址]:[端口号] https_proxy=http: //[服务器地址]:[端口号] ``` 然后重启snapd服务: ``` sudo systemctl restart snapd ``` Source https://www.jianshu.com/p/0891648b657a ###方法三 A system option was added in snap 2.28 to specify the proxy server. ```shell $ sudo snap set system proxy.http="http://
:
" $ sudo snap set system proxy.https="http://
:
" ``` [Documentation](https://docs.snapcraft.io/system-options "Documentation") | [Source](https://askubuntu.com/questions/764610/how-to-install-snap-packages-behind-web-proxy-on-ubuntu-16-04 "Source")
本篇文章采用
署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
许可协议进行许可。
None
发表评论
暂无评论
textsms
说点什么...
内容不能为空
account_circle
昵称
昵称不能为空
email
邮箱
请按格式填写邮箱
link
网站
请按格式填写网站
取消回复
提交评论
keyboard_arrow_up