Maximum protection: set up your route (WordPress, Cloudflare, PHP, nginx or Apache)
Step-by-step instructions for the three ready-made routes, how to test them, and what the usual mistakes look like.
On this page
Maximum protection (Pro and Plus) adds a route on your own domain, so AdCobalt keeps working when our address is blocked for a visitor. You set it up once; it serves all your websites that use the same route path.
Open any website on Websites, go to the Install tab and find Maximum Protection Setup. Pick how your website is run: WordPress plugin, Cloudflare Worker, PHP file or nginx or Apache. The dashboard then shows the steps in the right order. Each step says where it happens (In AdCobalt, In Cloudflare, On your hosting...), shows a small picture of that screen, and ticks itself off where AdCobalt can tell. Your progress is remembered.
Which one? On WordPress? Use the WordPress plugin. Is your site on Cloudflare? Use the Worker. Shared hosting with cPanel or a similar control panel? Use the PHP file. Your own server (a VPS or a dedicated server)? Use the nginx or Apache settings.
When your route gets a new path
If a filter list or a public rule request ever names your route path, AdCobalt gives your route a new path at once, before it can block anything, and tells you by email and in the bell. The old path keeps working for 7 days. What happens next depends on your setup:
- WordPress plugin, Cloudflare Worker in automatic mode, PHP file with the PHP line in your template: nothing to do. They switch by themselves within the hour.
- PHP file on plain HTML pages: the new folder is created by itself on most hosts; replace the AdCobalt code on your pages with the new one.
- Cloudflare Worker in route only mode, nginx or Apache: change the path in the Cloudflare route or the server block, and replace the code on your pages.
The More Options part of the setup shows this table for your account.
Cloudflare Worker
You need the Cloudflare account that runs your website.
One click (recommended): in Cloudflare, create an API token with three permissions: Account, Workers Scripts, Edit; Zone, Workers Routes, Edit; Zone, Zone, Read (the dashboard links to the token page). Paste the token in the dashboard and click Set Up My Route. AdCobalt creates a Worker called adcobalt-route with its own secret key, adds its route and runs Test my route. The token is used once and never stored; you can delete it in Cloudflare afterwards.
Two modes:
- Automatic: the route covers your whole site (
example.com/*). The Worker also adds the AdCobalt code to your pages, and a new path needs nothing from you. Every request to your site then passes through the Worker, which counts towards Cloudflare's free limit of 100,000 requests a day. Remove the AdCobalt code you added by hand, so it isn't on your pages twice. - Route only: only your route path passes through the Worker. After a new path, you update the Cloudflare route and your page code.
By hand: download the Worker under More, create a Worker in Workers & Pages with that code, add a variable of type Secret named ADCOBALT_KEY with your install key (never paste the key into the code), add the route (example.com/* for automatic mode, or your route path with a * at the end) and run Test my route.
The Worker passes on the visitor's country from Cloudflare and the visitor's address from CF-Connecting-IP, which Cloudflare sets itself.
PHP file (shared hosting)
- Create your install key in the dashboard: the files you download then have it filled in.
- In your website's main folder (often
public_htmlorwww), create the folder shown as your route path, for example/maple/k7q2/. - Upload
index.php,.htaccessandcode.phpinto it. - Run Test my route.
- Pages made by PHP: add the PHP line from the dashboard to the
<head>of your template instead of the AdCobalt code; it prints the current code, so a new path updates your pages too. Plain HTML pages: paste the page code.
The PHP file asks AdCobalt for its paths every hour, and creates the folder for a new path by itself when your host lets PHP create folders (most do).
The PHP file works with cURL, and without it through PHP's own streams (allow_url_fopen). It keeps a copy of the script for as long as AdCobalt's answer allows (at most an hour) in the server's temporary folder, which the web server never serves. Behind Cloudflare or another proxy you control, you can name the header that carries the visitor's address in the marked line TRUSTED_PROXY_HEADER; leave it empty otherwise, because visitors could fake it.
nginx or Apache (your own server)
- nginx: add the block inside the
server { }block of your website, paste your install key into the marked line, then runsudo nginx -t && sudo systemctl reload nginx. - Apache: add the block inside the
<VirtualHost>of your website, paste your install key into the marked line, enable the modules withsudo a2enmod proxy proxy_http headers ssl, then runsudo apachectl configtest && sudo systemctl reload apache2.
Behind Cloudflare or your own proxy, use nginx's real_ip module or Apache's mod_remoteip, so the visitor's real address is used. Optional caching lines for nginx are included as comments.
What Test my route tells you
- Green tick: the route works.
- The route doesn't contain your install key yet: paste it into the marked line (PHP, nginx, Apache) or add the
ADCOBALT_KEYsecret (Cloudflare). - Wrong key: the route sends an old or mistyped key, or another account's key. After Replace key, the old key works for 24 more hours.
- Nothing answers at your route path: the folder or the route path doesn't match the one in the dashboard.
- The .htaccess rewrite isn't active: the PHP file is there, but
.htaccessis missing (it starts with a dot, so some file managers hide it) or your host doesn't allow it. - PHP has neither cURL nor allow_url_fopen: ask your host to enable one of them.
- Wrong website address: the route sends a hostname that isn't one of your websites.
What every route does, and doesn't
- It only answers under your route path, and only for the requests AdCobalt needs.
- It never passes your visitors' cookies or login headers to AdCobalt, and never passes a cookie from AdCobalt back to your visitors.
- Your install key stays on your server: it never appears in your pages, and the routes never write it into an error message.
- If AdCobalt can't be reached, the route answers within a few seconds with an error, and your page carries on as usual.
For developers, the full protocol is in Maximum protection: how a route works.
Still stuck? Sign in and use Help & Support: it checks your setup and you can write to us from there.
Get help in your dashboard