Every host and framework
Set up Constile on Caddy
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 Caddy 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 CaddyAdd this to your site block in the Caddyfile. 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. # Put these lines in your site block. # Requests from the proxy itself carry Constile-Gate-Bypass, and go to your site. @constile `!header({'Constile-Gate-Bypass': '*'}) && ( path_regexp(r'^/sponsored/(?:deferred|prepared|delivered|content|offer)/') || path('/.well-known/constile') || header({'Signature': '*'}) || header_regexp('User-Agent', r'(?i)(?: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)') || !header_regexp('User-Agent', r'(?i)^mozilla/') || header_regexp('User-Agent', r'(?i)(?:bot\b|crawler|spider|headless|scraper)') )` handle @constile { reverse_proxy http://127.0.0.1:8080 } - 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 Caddy, for example
sudo systemctl reload caddy: 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 Caddy still sends agents to it.To take it out: Take out the lines, reload Caddy, then remove the container.Off or paused, people, search crawlers, subscribers, and your other ads get your site exactly as before.