How can I block access via VPN and proxy?

Hello, how can I block access to my website via VPN and proxy using Cloudflare’s free version?

Blocking VPNs & Proxies isn’t an easy task, I don’t think the free version has any tools to specifically target those.

You might be able to take a gamble and play with threat score and firewall rules but the results would likely be disappointing.

Is there a way to integrate a VPN and proxy IP checker with Cloudflare

eg: vpnapi io

You can use Cloudflare workers, however, if the API isn’t fast enough, your website speed will be affected.
With some optimizations in place, this effect would be less noticeable.

Feel free to ask in the Cloudflare discord if you want some guidance using CF workers

2 Likes
addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  // Kullanıcının gerçek IP adresini alın
  const userIP = request.headers.get('CF-Connecting-IP')

  // VPN kullanıldığını tespit etmek için VPN veritabanı API'sini kullanın
  const vpnCheck = await fetch('https://vpn.api.com/check?ip=' + userIP)

  // JSON yanıtını alın
  const vpnResponse = await vpnCheck.json()

  // Eğer VPN kullanılıyorsa, 403 Forbidden yanıtı gönderin
  if (vpnResponse.is_vpn) {
    return new Response('Forbidden', { status: 403 })
  }

  // VPN kullanılmıyorsa, isteği devam ettirin
  return fetch(request)
}

Thanks man, I fixed the problem.
i am a genius :smiling_face_with_three_hearts:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.