Skip to content

prerender/prerender-docker-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerender docker middleware

This standalone docker component can be used as a middleware to prerender your website with Prerender.io when you can’t use other middlewares (or simply when you prefer to do it this way).

How-To

Docker middleware

  1. Assign a secondary domain to your website.

E.g. if your website is www.example.com (primary domain), then point www2.example.com (secondary domain) to your website too.

Don't add the secondary domain name as a CNAME for your primary domain, as you will need to re-point your primary domain to this docker component at the end of the setup. Use an A or AAAA record instead. Or use a CNAME that is provided by your hosting provider, but doesn't match your primary domain.

  1. Edit the Dockerfile to match your settings.

Set your secondary domain, primary domain and API key. You may want to use environment variables later, but we suggest you do it in the file first to avoid environment compatibility issues during your first setup.

  1. Optional: At this point, you can test your setup locally by running the docker container on your computer. For this, you need to have a configured Docker Engine or Docker desktop running on your computer.
make run
curl http://localhost:8080
  1. Setup this docker container to run as a standalone server.

This step highly depends on your infrastructure so it's hard to give you more suggestions here. Still, a common step is to upload this dockerfile to a component-based cloud provider, such as Digital Ocean App Platform, Heroku, AWS ECS or Elastic Beanstalk. Or use your already existing, Docker-capable kubernetes cluster, as you like.

  1. Point your primary domain to this new component.

At this point you're good to use a CNAME too, as this is a brand new component.

  1. Test

Send a few request to your primary domain using curl, and see how it responds to different user agents.

Emulate a normal user request

The user agent could be anything that doesn't look like a bot, we just added something here for clarity.

curl -A Chrome https://www.example.com

Emulate a bot request

curl -A Googlebot https://www.example.com

Optional: You can even set your secondary domain to be authenticated (e.g. with basic auth), so then it will never be indexed by Google, and modify the nginx config to send the authentication along with the request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published