linux 下 chrome 无法在设置里面配置代理的解决方法

文章目录

    • @[toc]
    • 解决方法
      • 查找 chrome 命令路径
      • 查看 chrome 启动文件
        • 方式一
        • 方法二

在 linux 环境下,使用 chrome 没办法像 firefox 一样在设置里面配置代理,打开 chrome 的设置会有下面的内容显示

When running Google Chrome under a supported desktop environment, the system proxy settings will be used. However, either your system is not supported or there was a problem launching your system configuration.

But you can still configure via the command line. Please see man google-chrome for more information on flags and environment variables.

解决方法

查找 chrome 命令路径

  • 这个名字大家以自己实际的为准,理论上都是一样的
whereis google-chrome-stable

返回的信息如下

google-chrome-stable: /usr/bin/google-chrome-stable /usr/share/man/man1/google-chrome-stable.1.gz

查看命令是什么类型的文件

file /usr/bin/google-chrome-stable

他是一个 shell script,不是二进制文件

/usr/bin/google-chrome-stable: Bourne-Again shell script, ASCII text executable

查看 chrome 启动文件

大家自己 cat 一下文件,这里以我的文件来提供思路

#!/bin/bash

XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-~/.config}

# Allow users to override command-line options
if [[ -f $XDG_CONFIG_HOME/chrome-flags.conf ]]; then
    CHROME_USER_FLAGS="$(grep -v '^#' $XDG_CONFIG_HOME/chrome-flags.conf)"
fi

# Launch
exec /opt/google/chrome/google-chrome $CHROME_USER_FLAGS "$@"
方式一

最简单粗暴的方法,就是在最后一行的命令后面加 --proxy-server 参数,后面带上自己代理服务器的地址和端口(记得使用 root 权限修改这个文件)

--proxy-server="127.0.0.1:12333"
方法二

根据脚本内的 XDG_CONFIG_HOME 变量,在 ~/.config 目录下创建一个 chrome-flags.conf 文件,里面加上 --proxy-server 参数,当然也可以自己修改脚本,总的思路就是给 chrome 的启动命令加上 --proxy-server 这个参数

如果代理服务器关了,chrome 就会连百度都打不开,这个只能大家酌情处理了

你可能感兴趣的:(Linux,linux,chrome)