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

Nginx Integration Guide

This guide will show you how to integrate Prerender into your Nginx webserver. It includes a video tutorial and a comprehensive written guide covering all major use cases for Nginx.

 

Integrating Prerender into Your Nginx Server

This guide will walk you through integrating Prerender into your Nginx server for three common use cases: Single Page Applications (SPA), PHP applications, and Reverse Proxies.

To determine the appropriate Nginx Prerender integration, you need to consider your usage of Nginx. Below is a list of the most common use cases along with their corresponding GitHub links. Further down, you'll find video and text guides with corresponding titles.

All example configurations are available on this GitHub link below.
View source on GitHub.

View the Nginx config here.

Nginx Use Cases for Prerender Integration

 

Tips for Success:

  • Always back up your Nginx config file before making changes.

  • Make sure to test your Nginx configuration after every change to avoid downtime.

 

Single Page Application

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.

Text guide:

1. Open the Nginx Single Page Application code on our GitHub repository.

2. It is recomended to make a backup from the Nginx config file.

3. Add the map{...} sections from Github under your http{...} blocks in the config file.

image(52)

4. Add the following code section to your location / {..} block

            if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}

image(53)

5. Add the location /prerenderio {...} block to your server block under the location / {..} block.
image(54)

6. Replace the YOUR_TOKEN place holder with your Prerender.io Token from the Security and Access menu.

7. Run a Nginx config test and restart it if successful.

 


 

PHP Application

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.

Text guide:

1. Open the Nginx PHP application code on our GitHub repository.

2. It is recomended to make a backup from the Nginx config file.

3. Add the map{...} sections from Github in fron of the server block in the config file.

image(55)

4. Add the following code section to your location / {..} block

        location / {
if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}
rewrite (.*) /index.php$1 last;
}

image(56)

5. Add the location /prerenderio {...} block to your server block under the location / {..} block.
image(57)

6. Replace the YOUR_TOKEN place holder with your Prerender.io Token from the Security and Access menu.

7. Add the following if statement in your ~ [^/].php(/|$) location block:

            if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}

image(58)

8. Run a Nginx config test and restart it if successful.

 


 

Reverse proxy

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.

Text guide:

1. Open the Nginx Reverse proxy code on our GitHub repository.

2. It is recomended to make a backup from the Nginx config file.

3. Add the map{...} sections from Github under your http{...} blocks in the config file.

image(52) (1)

4. Add the following code section to your location / {..} block

            if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}

image(53) (1)

5. Add the location /prerenderio {...} block to your server block under the location / {..} block.
image(54) (1)

6. Replace the YOUR_TOKEN place holder with your Prerender.io Token from the Security and Access menu.

7. Run an Nginx config test and restart it if successful.

 


 

Verify Your Installation

After integration, it’s important to verify that everything is working as expected. We’ve provided an easy-to-follow guide to help you test your setup and confirm that Prerender is functioning properly.

 

Is the Prerender integration working on other pages?

Test if the Prerender integration works on the other pages based on this guide: Verify the integration

If you don't see the Prerender headers / IDs, then the Integration is not working, which might be why the other URL is not cached

 

Getting an Error?

If you see the message "Prerender Integration Not Detected," you can refer to the troubleshooting guide here to help resolve the issue.

 

Expert Assistance

For those who need additional help or want to ensure a smooth and secure launch, we offer a specialized package:

Kickstart Package

Price: $800 (one-time payment)

This one-time package empowers you with expert setup and configuration, ensuring a smooth and secure launch.

Features:

  • Three setup and configuration sessions with our experts
  • Onboarding assistance
  • Security assessment

To learn more about this package or to purchase, visit the Packages section under the Billing menu in your Prerender dashboard. 


 

Get Support

If you're still encountering issues after implementing Prerender:

  • Review your implementation against our documentation
  • Contact our support team:

To help us resolve your issue as quickly as possible, please gather and include any relevant information, such as:

  • Error messages you're seeing
  • Steps you've already taken to troubleshoot
  • Screenshots or screen recordings (if applicable)

Providing these details up front will help our team diagnose the problem more efficiently and get you back on track faster.

 

Related Articles / FAQs