Using FlareSolverr with n8n: Access Cloudflare protected websites

Written by

Jannick Nijholt

Published on

13/11/2024

Last update

13/11/2024
BlogUncategorized

Working with websites protected by Cloudflare can be challenging when automating workflows in n8n. After encountering this issue myself, I found FlareSolverr to be an excellent solution. I’ve got it running on my Proxmox server using the Proxmox VE Helper-Scripts, and today I’ll show you how to use it effectively with n8n.

What is FlareSolverr?

FlareSolverr acts as a proxy server specifically designed to bypass Cloudflare protection. When it receives a request, it launches a Chrome browser instance, solves any Cloudflare challenges, and returns the webpage content along with the necessary cookies. This makes it perfect for automation tools like n8n where you need to access Cloudflare-protected websites programmatically.

Why Use FlareSolverr with n8n?

There are several reasons to integrate FlareSolverr into your n8n workflows:

  • Automated bypass of Cloudflare protection without manual intervention
  • Reliable access to protected websites in your automated workflows
  • Ability to scrape data from Cloudflare-protected sites
  • Seamless integration with n8n’s HTTP Request nodes

Using FlareSolverr in n8n

Setting Up the HTTP Request Node

To use FlareSolverr in n8n, you’ll need to configure an HTTP Request node with these basic settings:

{
  "url": "http://your-flaresolverr-ip:8191/v1",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json"
  }
}

Basic Request Example

Here’s a simple request body to get started:

{
  "cmd": "request.get",
  "url": "https://cloudflare.com",
  "maxTimeout": 60000
}

Common Use Cases

1. Simple GET Request

{
  "cmd": "request.get",
  "url": "https://protected-site.com",
  "maxTimeout": 60000
}

2. POST Request with Data

{
  "cmd": "request.post",
  "url": "https://protected-site.com/api",
  "postData": "param1=value1&param2=value2",
  "maxTimeout": 60000
}

3. Using Sessions

{
  "cmd": "sessions.create",
  "session": "my_session"
}

Best Practices

  1. Always set a reasonable maxTimeout value to prevent hanging workflows
  2. Use sessions when making multiple requests to the same site
  3. Keep your FlareSolverr instance’s resources in check, as each request creates a new browser instance

Troubleshooting Tips

If you encounter issues, check these common points:

  • Verify FlareSolverr is running and accessible from n8n
  • Ensure the correct Content-Type header is set
  • Check if the target URL is correctly formatted
  • Monitor FlareSolverr logs for potential errors

Remember that FlareSolverr is a powerful tool, but it does consume significant resources since it runs a full browser instance for each request. Plan your workflows accordingly and consider implementing delays between requests for optimal performance.

Profile Picture of Jannick Nijholt

Question, comment or an idea?

Shoot me an email!
You can reach me on [email protected]