Microsoft Edge和Google Chrome同理。

问题症状

启动了代理工具(如Steam++)并手动设置了系统代理
export ALL_PROXY="socks5://127.0.0.1:8868"
执行env|grep -i proxy得到回显当前的代理准确无误,但是浏览器无法正常使用(据说FireFox可能可以自动识别到系统代理?)
启动浏览器打开设置->高级->系统->打开您计算机的代理设置 浏览器跳转到chrome://linux-proxy-config页面,页面内容如下:

在受支持的桌面环境中运行Chromium时,将使用系统代理设置。但您的系统不受支持,或启动系统配置时出现问题。
但您仍可通过命令行进行配置。如需详细了解各项实验功能和环境变量,请参见 man chromium。

之前我一直不在意这个提示,但是今天凌晨突然很想解决代理不生效的问题,所以仔细回来看了看提示。
好吧,不支持当前桌面环境,那么我们按照提示全找找man chromium写了什么。
在proxy相关里有如下内容:

--proxy-server=host:port
       Specify the HTTP/SOCKS4/SOCKS5 proxy server to use for requests.

       This overrides any environment variables or settings picked  via
       the  options  dialog.   An  individual proxy server is specified
       using the format:

         [<proxy-scheme>://]<proxy-host>[:<proxy-port>]

       Where <proxy-scheme> is the protocol of the proxy server, and is
       one of:

         "http", "socks", "socks4", "socks5".

       If  the  <proxy-scheme>  is omitted, it defaults to "http". Also
       note that "socks" is equivalent to "socks5".

       Examples:

         --proxy-server="foopy:99"
             Use the HTTP proxy "foopy:99" to load all URLs.

         --proxy-server="socks://foobar:1080"
             Use the SOCKS v5 proxy "foobar:1080" to load all URLs.

         --proxy-server="socks4://foobar:1080"
             Use the SOCKS v4 proxy "foobar:1080" to load all URLs.

         --proxy-server="socks5://foobar:66"
             Use the SOCKS v5 proxy "foobar:66" to load all URLs.

       It is also possible to specify a separate proxy server for  dif‐
       ferent URL types, by prefixing the proxy server specifier with a
       URL specifier:

       Example:

         --proxy-server="https=proxy1:80;http=socks4://baz:1080"
             Load https://* URLs using the HTTP proxy "proxy1:80".  And
       load http://*
             URLs using the SOCKS v4 proxy "baz:1080".

--no-proxy-server
       Disables  the proxy server.  Overrides any environment variables
       or settings picked via the options dialog.

--proxy-auto-detect
       Autodetect proxy configuration.  Overrides any environment vari‐
       ables or settings picked via the options dialog.

显然,我们得手动在Chromium启动参数上加上设置代理的参数。按照上面的例子,我应该添加如下参数:
--proxy-server="socks://127.0.0.1:8868"
所以,编辑桌面快捷方式(后缀为.desktop),找到Exec这行,改为:
Exec=chromium %U --proxy-server="socks://127.0.0.1:8868"
记得保存,大功告成,去试试你的代理吧!

如果关闭代理工具后浏览器访问网络产生异常,建议去复制一个新的快捷方式而不是直接修改原有的启动文件。
截图_2022-05-04_01-48-55.png

标签: none

添加新评论