Skip to content

Proxy server to bypass Cloudflare protection

License

Notifications You must be signed in to change notification settings

wangkai2014/FlareSolverr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlareSolverr

Proxy server to bypass Cloudflare protection

⚠️ This project is in beta state. Some things may not work and the API can change at any time. See the known issues section.

How it works

FlareSolverr starts a proxy server and it waits for user requests in idle state using few resources. When some request arrives, it uses puppeteer with the stealth plugin to create an headless browser (Firefox). It opens the URL with user parameters and waits until the Cloudflare challenge is solved (or timeout). The HTML code and the cookies are sent back to the user and those cookies can be used to bypass Cloudflare using other HTTP clients.

NOTE: Web browsers consume a lot of memory. If you are running FlareSolverr on a machine with few RAM, do not make many requests at once. With each request a new browser is launched.

Installation

It requires NodeJS.

Run PUPPETEER_PRODUCT=firefox npm install to install FlareSolverr dependencies.

Usage

Run node index.js to start FlareSolverr.

Example request:

curl -L -X POST 'http://localhost:8191/v1' \
-H 'Content-Type: application/json' \
--data-raw '{
	"url":"http://www.google.com/",
	"userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0",
	"maxTimeout": 60000
}'
Parameter Notes
url Mandatory
userAgent Optional. Will be used by the headless browser
maxTimeout Optional. Max timeout to solve the challenge
cookies Optional. Will be used by the headless browser. Follow this format https://github.com/puppeteer/puppeteer/blob/v3.3.0/docs/api.md#pagesetcookiecookies

Example response:

{
  "status": "ok",
  "message": "",
  "startTimestamp": 1591679463498,
  "endTimestamp": 1591679472781,
  "version": "1.0.0",
  "solution": {
    "url": "https://www.google.com/?gws_rd=ssl",
    "response": "<!DOCTYPE html><html ...",
    "cookies": [
      {
        "name": "ANID",
        "value": "AHWqTUnRRMcmD0SxIOLAhv88SiY555FZpb4jeYCaSNZPHtYyBuY85AmaZEqLFTHe",
        "domain": ".google.com",
        "path": "/",
        "expires": 1625375465.915947,
        "size": 68,
        "httpOnly": true,
        "secure": true,
        "session": false,
        "sameSite": "None"
      },
      {
        "name": "1P_JAR",
        "value": "2020-6-9-5",
        "domain": ".google.com",
        "path": "/",
        "expires": 1594271465,
        "size": 16,
        "httpOnly": false,
        "secure": true,
        "session": false
      }
    ],
    "userAgent": " Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0"
  }
}

Environment variables

To set the environment vars in Linux run export LOG_LEVEL=debug and then start FlareSolverr in the same shell.

Name Default value
LOG_LEVEL info
LOG_HTML false
PORT 8191
HOST 0.0.0.0

Docker

You can edit environment variables in ./Dockerfile and build your own image.

docker build -t flaresolverr:latest .
docker run --restart=always --name flaresolverr -p 8191:8191 -d flaresolverr:latest

Known issues / Roadmap

The current implementation is not able to bypass Cloudflare because they are detecting the headless browser. I hope this will be fixed soon in the puppeteer stealth plugin

TODO:

  • Fix remaining issues in the code (see TODOs)
  • Make the maxTimeout more accurate (count the time to open the first page)
  • Add support for more HTTP methods (POST, PUT, DELETE ...)
  • Add support for user HTTP headers
  • Hide sensitive information in logs
  • Reduce Docker image size
  • Docker image for ARM architecture
  • Install instructions for Windows

About

Proxy server to bypass Cloudflare protection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 87.2%
  • Dockerfile 12.8%