vps自建浏览器Firefox in a docker

date
Feb 1, 2022
slug
newservice-vps-firefox-docker
status
Published
summary
新服务 vps上自建远程浏览器 jlesagefirefox
tags
service
browser
type
Post
notion image

Summary

notion image
notion image

步骤

#1 运行docker - 不用ssl; 之后配置反代

export DOCKER_NAME='jlesagefirefox'
export DOCKER_PORT=5800
export DOCKER_PASSWORD='VNCPassword'
mkdir -p /data/$DOCKER_NAME/config; cd /data/$DOCKER_NAME
wget -O seccomp_profile.json https://raw.githubusercontent.com/moby/moby/master/profiles/seccomp/default.json



docker run -d \
  --name=$DOCKER_NAME \
  -e TZ=America/Los_Angeles \
  -e DISPLAY_WIDTH=1920 \
  -e DISPLAY_HEIGHT=1080 \
  -e KEEP_APP_RUNNING=1 \
  -e ENABLE_CJK_FONT=1 \
  -e VNC_PASSWORD=$DOCKER_PASSWORD \
  -p $DOCKER_PORT:5800 \
  -v $(pwd)/config:/config:rw \
  --security-opt seccomp=$(pwd)/seccomp_profile.json \
  --shm-size 1500m \
  jlesage/firefox

# 不用这个
# -e SECURE_CONNECTION=1 






# docker-composer.yaml
cat > docker-compose.yml <<EOF
version: "3"
services:
  ${DOCKER_NAME}:
    image: jlesage/firefox
    container_name: ${DOCKER_NAME}
    environment:
      - TZ=America/Los_Angeles
      - DISPLAY_WIDTH=1920
      - DISPLAY_HEIGHT=1080
      - KEEP_APP_RUNNING=1
      - ENABLE_CJK_FONT=1
      - VNC_PASSWORD=${DOCKER_PASSWORD}
    #ports:
    #  - ${DOCKER_PORT}:5800
    volumes:
      - ./config:/config:rw
    security_opt:
      - seccomp:./seccomp_profile.json
    shm_size: '1500m'

networks:
  default:
    name: npm_nginx_proxy_manager-network
    external: true
EOF

docker-compose down; docker-compose up -d; sleep 1s; docker-compose logs -f




#2 建立cloudflare条目+proxy+宝塔网站

notion image
notion image
notion image
location /
{
    proxy_pass http://jlesagefirefox:5800;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

### added
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Upgrade $http_upgrade;
#		proxy_set_header Connection $connection_upgrade;
		proxy_read_timeout 86400;
   
    add_header X-Cache $upstream_cache_status;
    
    #Set Nginx Cache
    
    	add_header Cache-Control no-cache;
}

	location /websockify {
    proxy_pass http://jlesagefirefox:5800;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header Upgrade $http_upgrade;
#		proxy_set_header Connection $connection_upgrade;
		proxy_read_timeout 86400;
	}
#PROXY-END/

验证

notion image
notion image
notion image
notion image

Compose


cat > docker-compose.yml <<EOF
version: '3.3'
services:
    jlesagefirefox:
        container_name: jlesagefirefox
        environment:
            - TZ=Asia/Hong_Kong
            - DISPLAY_WIDTH=1920
            - DISPLAY_HEIGHT=1080
            - KEEP_APP_RUNNING=1
            - ENABLE_CJK_FONT=1
            - VNC_PASSWORD=VNCPassfire
        #ports:
        #    - '11088:5800'
        security_opt:
            - seccomp:./seccomp_profile.json
        volumes:
            - './config:/config:rw'
        image: jlesage/firefox
        shm_size: '2g'

networks:
  default:
    name: npm_nginx_proxy_manager-network
    external: true
EOF

© Ying Bun 2021 - 2024