使用 jlesage/firefox 镜像搭建一个Web版浏览器
侧边栏壁纸
  • 累计撰写 195 篇文章
  • 累计收到 1,355 条评论

使用 jlesage/firefox 镜像搭建一个Web版浏览器

萧瑟
2025-02-08 / 7 评论 / 50 阅读 / 正在检测是否收录...

jlesage/firefox 是一个web版firefox浏览器,可以使用docker中运行web版浏览器,很是方便。

运行命令

docker run -d \
    --name=firefox \
    -p 5800:5800 \
    -v /docker/appdata/firefox:/config:rw \
    jlesage/firefox

中文乱码异常

异常截图

查阅GitHub文档发现有一个环境变量可以解决这个问题;

ENABLE_CJK_FONT:When set to 1, open-source computer font WenQuanYi Zen Hei is installed. This font contains a large range of Chinese/Japanese/Korean characters.

默认是0,这个意思是 当设置为1时,将安装开源计算机字体WenQuanYi Zen Hei。此字体包含大量中文/日文/韩文字符。

能解决这个异常问题;

安全问题

如果暴露在外网后,容易遭受攻击,所以该容器又提供了一个密码设置的环境变量VNC_PASSWORD

docker run -d \
    --name=firefox \
    -p 5800:5800 \
    -v /docker/appdata/firefox:/config:rw \
    -e VNC_PASSWORD=123456 \
    jlesage/firefox

Nginx 反代配置

参考文档,配置如下:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

upstream docker-firefox {
    # If the reverse proxy server is not running on the same machine as the
    # Docker container, use the IP of the Docker host here.
    # Make sure to adjust the port according to how port 5800 of the
    # container has been mapped on the host.
    server 127.0.0.1:5800;
}

server {
    [...]

    server_name firefox.domain.tld;

    location / {
            proxy_pass http://docker-firefox;
    }

    location /websockify {
        proxy_pass http://docker-firefox;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 86400;
    }
}

二级目录

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

upstream docker-firefox {
    # If the reverse proxy server is not running on the same machine as the
    # Docker container, use the IP of the Docker host here.
    # Make sure to adjust the port according to how port 5800 of the
    # container has been mapped on the host.
    server 127.0.0.1:5800;
}

server {
    [...]

    location = /firefox {return 301 $scheme://$http_host/firefox/;}
    location /firefox/ {
        proxy_pass http://docker-firefox/;
        # Uncomment the following line if your Nginx server runs on a port that
        # differs from the one seen by external clients.
        #port_in_redirect off;
        location /firefox/websockify {
            proxy_pass http://docker-firefox/websockify/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_read_timeout 86400;
        }
    }
}

评论 (7)

取消
  1. 头像
    XiaoShi
    广西壮族自治区桂林市叠彩区 Windows 10 · Google Chrome

    -e VNC_PASSWORD=123456;ENABLE_CJK_FONT=1 \

    这样?

    回复
  2. 头像
    zeruns
    广东省佛山市顺德区 Windows 10 · Google Chrome

    套娃浏览器是吧

    回复
    1. 头像
      萧瑟 作者
      北京市 Windows 10 · Microsoft Edge
      @ zeruns

      对,套娃表情

      回复
  3. 头像
    网友小宋
    河南省漯河市源汇区 Windows 10 · Microsoft Edge

    飞牛自带了一个。

    回复
    1. 头像
      萧瑟 作者
      北京市 Windows 10 · Microsoft Edge
      @ 网友小宋

      飞牛那个我还没试过,有空试试

      回复
  4. 头像
    acevs
    山东省青岛市城阳区 Windows 10 · Google Chrome

    搭建过,因为某个服务忘记了。
    后来发现用处不大。

    回复
    1. 头像
      萧瑟 作者
      北京市 Windows 10 · Microsoft Edge
      @ acevs

      服务组网后,用途确实不大。

      回复