Proxy pass from NGINX to domain name controlled by Cloudflare

I have an example website just for a proof of concept that I am developing. There is a dynamic rendering service as well for rendering the pages from that website. This is all behind a NGINX server and depending on the User-Agent header, the server proxy passes to the dynamic rendering service or ignores it and takes the user to the website itself.

One of the requirements is this dynamic rendering service must be caching content. I thought I could cache some content using Cloudflare so I “proxy passed” the request to “” and I keep getting 502 Bad Gateway. When I change it to HTTP I can see a redirect loop.

So, basically what I am doing is this:

if ($prerender = 1) {

Both website and the dynamic rendering service are proxied by Cloudflare which points to my NGINX server. I also did some research and I could not find anything relevant regarding this topic.

Any suggestions would be gratefully received.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.