Skip to content
  • There are no suggestions because the search field is empty.

How do I integrate Prerender.io with Azure App Service?

Enable URL rewriting on Azure App Service and forward crawler requests to Prerender.io, with no middleware to install.

TL;DR

On Azure App Service you integrate Prerender.io with two files: an applicationHost.xdt file that turns on URL rewriting, and a rewrite rule in your web.config that forwards AI crawlers and search engine bots to Prerender.io. You need FTP access to your App Service and your Prerender.io token.

Why Azure App Service needs its own guide

On a standard IIS server you enable Application Request Routing in IIS Manager and match the host with {HTTP_HOST}. Azure App Service does not give you that access, and it sits behind a load balancer, so {HTTP_HOST} is the internal host rather than your real domain. This guide enables rewriting through an applicationHost.xdt transform instead, and forwards the real domain to Prerender.io using the {HTTP_X_FORWARDED_HOST} header that Azure adds to each request.

Step 1: create a Prerender.io account and copy your token.

If you do not have a Prerender.io account yet, sign up at prerender.io. Once logged in, open Security & Access in your Prerender.io dashboard and copy your Prerender.io token. You will add it to your web.config in Step 4.

Step 2: create the applicationHost.xdt file.

This file enables the rewrite proxy, allows Prerender.io's token header through, and turns the App Service output cache off. Create a file named applicationHost.xdt with exactly this content:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.webServer>
    <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false"
      reverseRewriteHostInResponseHeaders="false" />
    <cache enabled="false" />
    <rewrite>
      <allowedServerVariables>
        <add name="HTTP_X_PRERENDER_TOKEN" xdt:Transform="InsertIfMissing" />
      </allowedServerVariables>
    </rewrite>
  </system.webServer>
</configuration>

 

ℹ️ The original integration disables the output cache because leftover cached responses can otherwise interfere while you set this up. Once the integration is confirmed working, you can try removing that line if you want App Service output caching back.

Step 3: upload applicationHost.xdt to your App Service.

Connect to your App Service over FTP and upload applicationHost.xdt to the /site folder, one level above /site/wwwroot. An FTP client such as FileZilla works well. Your FTP/FTPS credentials are in the Azure portal under your App Service's Deployment Center, if FTP/FTPS deployment is enabled.

⚠️ The file must sit in /site, not in /site/wwwroot. The transform is applied from the /site folder, so a file uploaded to /site/wwwroot will not take effect.

Step 4: add the rewrite rule to your web.config.

Open your application's web.config and add the following rule inside the <system.webServer> element. Replace YOUR_TOKEN with the token you copied in Step 1.

<rewrite>
  <rules>
    <rule name="Prerender.io rewrite rule" stopProcessing="true">
      <match url="(\.js|\.json|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff|\.svg)" negate="true" />
      <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_USER_AGENT}" pattern="googlebot|adsbot-google|apis-google|mediapartners-google|google-safety|feedfetcher-google|googleproducer|google-site-verification|bingbot|yandexbot|yabrowser|yahoo|baiduspider|naver|seznambot|sznprohlizec|qwantbot|ecosia|duckduckbot|duckassistbot|applebot|facebookexternalhit|facebookcatalog|facebookbot|meta-externalagent|instagram|twitterbot|linkedinbot|whatsapp|slackbot|pinterest|pinterestbot|tiktok|tiktokspider|bytespider|discordbot|semrushbot|ahrefsbot|chrome-lighthouse|screaming-frog|oncrawlbot|botifybot|deepcrawl|lumar|rogerbot|dotbot|gptbot|chatgpt|oai-searchbot|chatgpt-user|claudebot|google-extended|perplexitybot|perplexity-user|youbot|amazonbot|anthropic-ai|claude-web|ccbot|mistralai-user|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest/0\.|vkShare|W3C_Validator|redditbot|flipboard|tumblr|bitlybot|skypeuripreview|nuzzel|google\ page\ speed|qwantify|bitrix\ link\ preview|xing-contenttabreceiver|google-inspectiontool|telegrambot" />
        <add input="{QUERY_STRING}" pattern="_escaped_fragment_" />
      </conditions>
      <serverVariables>
        <set name="HTTP_X_PRERENDER_TOKEN" value="YOUR_TOKEN" />
      </serverVariables>
      <action type="Rewrite" url="https://service.prerender.io/https://{HTTP_X_FORWARDED_HOST}{REQUEST_URI}" logRewrittenUrl="true" />
    </rule>
  </rules>
</rewrite>

The rule forwards requests from known AI crawlers and search engine bots to Prerender.io, and leaves static files and requests from website visitors untouched.

ℹ️ The rewrite target uses {HTTP_X_FORWARDED_HOST}, not {HTTP_HOST}, because Azure App Service passes your real domain in the X-Forwarded-Host header. It also uses https:// for the forwarded address, so Prerender.io fetches your site over HTTPS. This assumes your site is served over HTTPS.

Step 5: restart your App Service.

Restart the App Service from the Azure portal so both files take effect. Wait for the site to go offline and come back before you test, or your changes will not be loaded yet.

Step 6: verify your integration is working.

Confirm that Prerender.io is intercepting crawler requests and serving rendered HTML.

➡️ See How to verify your Prerender.io integration is working for step-by-step instructions.

✅ Your integration is working when cached pages appear in your Prerender.io dashboard within 2 to 5 minutes of your first crawler request, and a simulated Googlebot request to your site returns a fully rendered HTML response served by Prerender.io.

ℹ️ If your App Service sits behind Azure Front Door or Azure Application Gateway, this rule may not receive your real domain in X-Forwarded-Host (Application Gateway, for example, sends it as x-original-host). These setups need extra configuration, so this guide does not cover them. Contact support@prerender.io.

ℹ️ If verification fails, check that the applicationHost.xdt file is in /site (Step 3), your token is set correctly in the web.config rule (Step 4), and you restarted the App Service (Step 5).

💬 Still need help? If your Azure App Service integration is not forwarding crawler requests as expected, our support team can help you diagnose it. → Contact us at support@prerender.io

Related articles

 

 

Was this article helpful?