- Print
- DarkLight
- PDF
Nginx
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.
All example configs are available on this GitHub Link below.
View source on GitHub.
View the Nginx config here.
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.
Nginx use cases:
Single Page Application
Video Guide:
The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.
Text guide:
- Open the Nginx Single Page Application code on our GitHub repository.
- It is recomended to make a backup from the Nginx config file.
- Add the
map{...}
sections from Github under yourhttp{...}
blocks in the config file.
- Add the following code section to your
location / {..}
block
if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}
5. Add the location /prerenderio {...}
block to your server block under the location / {..}
block.
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 successfull.
PHP Application
Video guide:
The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.
Text guide:
- Open the Nginx PHP application code on our GitHub repository.
- It is recomended to make a backup from the Nginx config file.
- Add the
map{...}
sections from Github in fron of the server block in the config file.
- Add the following code section to your
location / {..}
block
location / {
if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}
rewrite (.*) /index.php$1 last;
}
- Add the
location /prerenderio {...}
block to your server block under thelocation / {..}
block.
- Replace the
YOUR_TOKEN
place holder with your Prerender.io Token from the Security and Access menu. - Add the following if statement in your ~ [^/].php(/|$) location block:
if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}
- Run a Nginx config test and restart it if successfull.
Reverse proxy
Video guide:
The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.
Text guide:
- Open the Nginx Reverse proxy code on our GitHub repository.
- It is recomended to make a backup from the Nginx config file.
- Add the
map{...}
sections from Github under yourhttp{...}
blocks in the config file.
- Add the following code section to your
location / {..}
block
if ($prerender = 1) {
rewrite (.*) /prerenderio last;
}
5. Add the location /prerenderio {...}
block to your server block under the location / {..}
block.
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 successfull.