Skip to content

seadfeng/headless-browser-clusters

Repository files navigation

Headless Browser Clusters

Local Development

# create .env
cp ./app/.env.example ./app/.env

# install chromium for test
npm run app:chromium:install

# start
npm run app:dev

headless: false for Development

curl -X POST http://127.0.0.1:3000/api/v1/fetch-dev \
     -H "Content-Type: application/json" \
     -H "X-Api-key: your_api_key" \
     -d '{ 
           "url": "https://api.ipify.org/?format=jsonp"
         }'

Local Build

# app
npm run app:build

# browser worker
npm run browser:build

Docker Quick Start

npm run start

# or

cd .docker/compose && docker compose up -d

curl test

curl -X POST http://127.0.0.1:3100/api/v1/fetch \
     -H "Content-Type: application/json" \
     -H "X-Api-key: your_api_key" \
     -d '{ 
           "url": "https://api.ipify.org/?format=jsonp"
         }'

curl with proxy

curl -X POST http://127.0.0.1:3100/api/v1/fetch \
     -H "Content-Type: application/json" \
     -H "X-Api-key: your_api_key" \
     -d '{ 
           "url": "https://api.ipify.org/?format=jsonp",
           "proxy": "http://user:[email protected]:8080"
         }'

Deploy

  1. self host init
ssh root@host "mkdir -p /home/deploy/app/headless-browser-clusters"
rsync -avz .docker/compose/ root@host:/home/deploy/app/headless-browser-clusters
  1. start
ssh root@host "cd /home/deploy/app/headless-browser-clusters && npm run start"