IIS Integration
  • 20 Jun 2024
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

IIS Integration

  • Dark
    Light
  • PDF

Article summary

Integrating Prerender.io with IIS can be achieved through URL rewrite rules in server configuration, without requiring middleware installation.

Azure IIS integration

The Azure App Services URL rewrite rules do not support specifying a different domain. Because fo this the Integration is different on this platform.
Please see the guide on the Azure IIS intgeration here.

Video guide

Prerender token

The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.

The required modules can be downloaded from the links below:
https://www.iis.net/downloads/microsoft/url-rewrite
https://www.iis.net/downloads/microsoft/application-request-routing

The required patterns and other strings can be found in the text guide below.

Text guide:

Prerequisites:

Add the rules

  1. Navigate to IIS manager > Select your server > Sites > Select your site > Open URL Rewrite.

  2. In the "Server Variables" section, add your Prerender.io Token from the Security and Access menu to be forwarded to us:

    1. Click Add...
    2. Server variable name: HTTP_X_PRERENDER_TOKEN
    3. Value: [YOUR TOKEN]
    4. Check "Replace the existing value"
  3. Click "Add rule(s)..." on the right-hand side and select "Blank rule".

  4. Name the rule (e.g. Prerender.io rewrite rule)

  5. Set up the "Match URL" section to look like this:

    1. Requested URL: Does Not Match the Pattern
    2. Using: Regular Expression
    3. Pattern: (\.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)
    4. Check ignore case if your site URLs are case insensitive
  6. Add two rules in the "Conditions" section:

    1. Rule 1:
      • Condition input: {HTTP_USER_AGENT}
      • Check if input string: Matches the Pattern
      • Pattern: googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp|redditbot|applebot|flipboard|tumblr|bitlybot|skypeuripreview|nuzzel|discordbot|google\ page\ speed|qwantify|bitrix\ link\ preview|xing-contenttabreceiver|chrome-lighthouse|telegrambot|google-inspectiontool
      • Check "Ignore case"
    2. Rule 2:
      • Condition input: {QUERY_STRING}
      • Check if input string: Matches the Pattern
      • Pattern: _escaped_fragment_
    3. Set the "Logical grouping" to "Match Any".
  7. Set up the "Action" section to match the following:

    1. Action type: Rewrite
    2. Rewrite URL: https://service.prerender.io/https://{HTTP_HOST}{REQUEST_URI}
    3. Uncheck "Append query string"
    4. To get better logging, check "Log rewritten URL" (optional)
    5. Check "Stop processing of subsequent rules" (optional, this may also depend on your setup)

Notes:

  • Change the "Rewrite URL" to use HTTP if your site enforces HTTP.
  • If you have special encoded characters in your URL
    • Use Rewrite URL: https://service.prerender.io/http://{HTTP_HOST}{UNENCODED_URL}
    • Set useOriginalURLEncoding to 'false'. To set the flag, start IIS Manager, select Configuration Editor, and go to the section system.webServer/rewrite/rules.
  • This setup guide is just a template. Your application may have special needs that need to be reflected in these rules.
  • This guide assumes that your IIS server is publicly accessible from the Internet. Suppose you want to set this up for a local development environment. In that case, you need to run the open-source Prerender component (https://github.com/prerender/prerender) locally on your computer, then use the URL of that service (e.g. http://localhost:3000) in point 7/b, replacing the https://service.prerender.io URL.

Was this article helpful?

What's Next