# Prevent Ad-blockers from blocking Mixpanel [Without Nginx!]

Most ad blockers block Mixpanel from sending events to the server. Since the number of people using ad-blockers or privacy-focused browsers is increasing, there is a dedicated post on Mixpanel's website to address this. However, the solutions they provide seemed unnecessary. We can use a reverse proxy and forward Mixpanel events via our domain.

If you are using a reverse proxy like Nginx, you can use [this](https://github.com/mixpanel/tracking-proxy/blob/126203cda52abd1564b8d82ab5dd88f67e7c27a5/nginx.conf) config, and you're good to go. However, if you are not using Nginx or want to use a lightweight solution, you can proceed with the following paragraphs.

### Option 1: Using CloudFront

* Create a CloudFront distribution.
    
* Create an origin with the origin domain, [https://api.mixpanel.com/](https://api.mixpanel.com/), and give it any name.
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658515661226/ghkjuB5m1.png align="left")

* Don't add any paths for the origin. By doing so, CloudFront will simply forward the path requested by the browser on your proxy domain to the Mixpanel API domain.
    
* Create a behavior and set the origin we just added from step #2.
    
* Use the default path pattern `(*)` and allow GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE methods and save. Otherwise, you will get a generic `Key Not Found` error while sending data.
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658515744604/qEazz55GE.png align="left")

* In your application, use this new URI instead of the regular `api.mixpanel.com`
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658516509736/FW-X-oQBq.png align="left")

```js
mixpanel.init (mixpanelToken, { api_host: newURI });
```

### Option 2: Using CloudFlare

* Add an `A record` to your CloudFlare domain with IP `127.0.0.1`, with the Proxy Status set to "DNS Only".
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658514629083/uqCPmIrVn.png align="left")

* Navigate to CloudFlare Workers and create a worker service.
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658514738742/r8Rsmvz4q.png align="left")

* Give it an appropriate name - like `mixpanel-proxy` and proceed to the next step.
    
* Now, edit the Worker script and add [this](https://gist.github.com/pranavpudasaini/6da9d1e722155c6486c4cf89f502dd9d.js) script. Credit goes to [CorsFlare by Darkseal](https://github.com/Darkseal/CORSflare/blob/e619ac0d36ba21f096b0a5dd702dd47dc93dc1cc/CORSflare.js)
    
* Navigate back to CloudFlare Workers, select the worker you just created, and go to `Triggers` tab and add a custom domain from step 1.
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658545030509/W4979P9MO.png align="left")

* Finally, test your CloudFlare by visiting the domain. If all is well, you will be greeted by the Mixpanel API page.
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658545356096/7EHgFGNCg.png align="left")

Just as you are bypassing ad-blocker, I'm doing something else to get your IP and browser information. Now, how do you like being tracked, huh? 😎

Find the ^flag\[A-Za-z\]$, comment, and DM me on [Twitter](https://twitter.com/_dimm3r_/) to get a surprise!

![ ](https://track.dim-sec.tech/not-worth-looking-into-or-is-it align="left")
