Every host and framework
Set up Constile on Apache
Constile's gate runs in front of your pages. An AI agent fetching a page for a person gets an offer; people, search engines, and subscribers get your site as they do today.- Build the gate's container
docker build -t constile-proxy https://constile.app/install/constile-proxy-0.6.0.tar.gz
- Run it next to your sitePut the settings in a file only you can read.
CONSTILE_ORIGINis where Apache reaches your site.CONSTILE_ORIGIN=http://host.docker.internal:3000 CONSTILE_SITE_ID=your-site-id CONSTILE_SITE_SECRET=your-site-secret CONSTILE_NETWORK_URL=https://constile.app CONSTILE_TRUSTED_PROXIES=172.17.0.1
chmod 600 constile.env docker run -d --name constile --restart unless-stopped \ --add-host host.docker.internal:host-gateway \ --env-file constile.env -p 127.0.0.1:8080:8080 constile-proxy
- Send agents to it from ApacheAdd this to your virtual host. It sends the gate's paths and AI agents to the container, and everyone else to your site as now. It's made from today's agent list; come back for a new copy when agents are added.
# Constile: send gate traffic to the Constile proxy at http://127.0.0.1:8080, # and everything else to your site as before. Generated for 16 agent tokens. # Needs mod_rewrite, mod_proxy, mod_proxy_http, and mod_headers. Put these lines in your # site's <VirtualHost>, before its other rewrite rules. RewriteEngine On # Requests from the proxy itself carry Constile-Gate-Bypass, and go to your site. RewriteCond %{HTTP:Constile-Gate-Bypass} ^$ RewriteCond %{REQUEST_URI} ^/sponsored/(?:deferred|prepared|delivered|content|offer)/ [OR] RewriteCond %{REQUEST_URI} ^/\.well-known/constile$ [OR] RewriteCond %{HTTP:Signature} . [OR] RewriteCond %{HTTP_USER_AGENT} (?:aider\x2f|anchor\x20browser|apifywebsitecontentcrawler|chatgpt-agent|chatgpt-user|claude-agent|claude-code\x2f|claude-user|duckassistbot|google-agent|google-gemini-cli|meta-externalfetcher|mistralai-user|modelcontextprotocol\x2f|opencode-user|perplexity-user) [NC,OR] RewriteCond %{HTTP_USER_AGENT} !^mozilla/ [NC,OR] RewriteCond %{HTTP_USER_AGENT} (?:bot\b|crawler|spider|headless|scraper) [NC] # The path as the visitor sent it, still encoded. Apache adds the query string itself. RewriteCond %{THE_REQUEST} ^\S+\s+(/[^?\s]*) RewriteRule ^ http://127.0.0.1:8080%1 [P,L,NE,E=constile_proto:%{REQUEST_SCHEME}] RequestHeader set X-Forwarded-Proto %{constile_proto}e env=constile_proto # mod_proxy adds your site's host name to X-Forwarded-Host; drop any the visitor sent. RequestHeader unset X-Forwarded-Host env=constile_proto - Check the installDeploy, then select Check install on your site's page. The network asks your domain for
/.well-known/constile, and the gate answers with your site secret. Then Test my site shows what a person, a search crawler, and an AI agent each get.
Turn it off
Fastest, from your dashboard: once the gate is installed, select Pause offers under Manage on your site's page. The network stops making offers, and the gate passes every request through within a minute. Nothing changes on your server.On your site: Take out the lines you added for the gate and reload Apache, for example
sudo systemctl reload apache: agents then go straight to your site. Or set CONSTILE_DISABLED=1 in constile.env, run docker rm -f constile, and run the container again with the same command: a restart keeps the old settings. Keep the container running while Apache still sends agents to it.To take it out: Take out the lines, reload Apache, then remove the container.Off or paused, people, search crawlers, subscribers, and your other ads get your site exactly as before.