I have a tech stack consisting of a Ruby on Rails backend, React-JS frontend hosted on S3, and the entire backend is orchestrated using Kubernetes. I've set up a prerender server following the prerender.io guidelines, and it's running fine independently.
The main goal is to have web crawlers receive a prerendered version of the website for SEO purposes.
However, when trying to integrate this prerender service into my existing setup, I've been facing some issues. Here is a summary of my setup and the issues:
- Rails Configuration:
- I have added the following middleware configuration in Rails to forward requests to the prerender service:
config.middleware.use Rack::Prerender, protocol: 'https'
config.middleware.use Rack::Prerender, prerender_service_url: 'https://prerender.xxx.com:3000'
- Kubernetes Ingress Configuration: I attempted to add an Nginx Ingress configuration to direct certain user agents to the prerender service directly, but this resulted in a 403 Forbidden error when accessing the service with a Googlebot user agent, for example.
nginx.ingress.kubernetes.io/configuration-snippet: |
...
if ($prerender = 1) {
rewrite .* /$scheme://prerender.xxx.com:3000/render?url=$scheme://$host$request_uri? break;
proxy_pass http://prerender.xxx.com:3000;
}
- Accessing Prerender Service:
When trying to access https://prerender.xxx.com:3000 directly, the request seems to hang forever, although curling the prerender service from the machine it's hosted on works fine.
I'm wondering if anyone has set up prerender.io alongside Kubernetes that can help solve this.
the closest I have got is getting a 403 when switching to googlebot user agent on dev tools