Docker Integration Guide
View source on Github. This standalone docker component can be used as a middleware to prerender your website with Prerender.io when you can't use other middleware (or simply when you prefer to do it this way).
Overview
Easily deploy Prerender using Docker for a scalable and efficient solution. This guide is designed for those who want to streamline their Prerender setup with containerized deployment. By leveraging Docker, you can quickly spin up a Prerender service with minimal configuration, ensuring high performance and reliability.
Step-by-step Guide
1. Assign a Secondary Domain to Your Website
-
Example: If your primary domain is
www.example.com
, create and point a secondary domain such aswww2.example.com
to your website.
-
Important:
-
Avoid adding the secondary domain as a CNAME for your primary domain.
-
Use an A or AAAA record instead or a CNAME provided by your hosting provider that doesn’t match your primary domain.
-
2. Edit the Dockerfile to Match Your Settings
-
Configure the Dockerfile to include your secondary domain, primary domain, and API key.
-
You may want to use environment but it is recommended to start with these values in the Dockerfile to avoid compatibility issues during the initial setup.
3. Test Locally (Optional)
-
Run the Docker container on your local machine for testing if you have a configured Docker Engine or Docker Desktop.
make run
curl http://localhost:8080
4. Deploy the Docker Container as a Standalone Server
-
Depending on your infrastructure, deploy the container to a service such as:
-
Digital Ocean App Platform
-
Heroku
-
AWS ECS
-
Elastic Beanstalk
-
-
Alternatively, use an existing Docker-capable Kubernetes cluster.
5. Point Your Primary Domain to the New Component
-
Once the new component is active, you can use a CNAME to point your primary domain to it.
6. Perform Testing
- Test your primary domain by sending requests using
curl
or similar tools. Observe the responses to ensure proper functionality across various user agents. - You can also follow this guide to test if it works.
Testing with curl Commands
Simulate a normal user request by sending a curl
command with a standard user agent string, such as:
curl -A Chrome https://www.example.com
For bot requests, emulate the behavior by specifying a bot-like user agent:
curl -A Googlebot https://www.example.com
Alternatively, you can simulate a bot-like user agent with the following command:
curl -v -A googlebot https://www.yourpage.com/
Run the following command to simulate a bot request as processed by Prerender, adding the necessary Prerender token:
curl -H "X-Prerender-Token: <YOUR_PRERENDER_TOKEN>" https://service.prerender.io/https://www.example.com/
- You can configure your secondary domain with authentication (e.g., basic auth) to prevent it from being indexed by search engines like Google. Additionally, modify your Nginx configuration to include the authentication credentials with each request.
Related Articles