Reverse Proxy using Page Rules

Is it possible to implement a reverse proxy using Cloudflare’s page rules?

Can this be achieved with the Re-Write Host Headers page rule? Is there another way to achieve this without signing up for an Enterprise plan?

Cloudflare IS a reverse proxy. What exactly would you like to accomplish and how would you imagine page rules to help?

Our Cloudflare DNS is pointing to our server running nginx which has a reverse proxy for a specified path, say www.example.com/some-other-app/.

I’ve been told that this can be achieved using Cloudflare’s page rules, but am not sure how to set that up.

What can be achieved? So basically you have Cloudflare pointed to a server which then proxies on to another machine?! And what exactly do you want to achieve?

Yes. I’d like to know if the reverse proxy can be achieved using page rules rather than nginx.

You ignored my question about you clarifying what you exactly want to achieve.

You dont need a page rule to proxy to a server proxying once more.

I’d like to have the reverse proxy be in Cloudflare and not in nginx.

So you want to get rid of your proxy?! You need to exactly describe what you want to proxy and in what way.

Yes I would like to get rid of the reverse proxy in nginx.

The reverse proxy currently passes requests for a path to another server and serves the response as if it came from the original server. It’s a simple reverse proxy using nginx’s proxy_pass command.

Thats exactly what Cloudflare does, it simply forwards the request. Why would you need a page rule?

As far as I know, Cloudflare’s DNS forward’s domain level requests, for example, example.com. I need to forward a specific URL, say, example.com/another-application. I was told I could achieve this using page rules, but am not sure how, unless you know how to achieve this another way.

It is still not clear what exactly you want to proxy and, pardon, I am not going to ask for a fourth time at this point.

But yes, Cloudflare certainly proxies sub-directories too.

Maybe you could tell me how to set up Cloudflare to proxy a subdirectory?

There is nothing you need to do, if you set up your domain it will automatically forward/proxy any request (including sub-directories) to your origin.

I need the subdirectory to go to a different server. Like I said, let’s say example.com goes to my current server, I want to set up Cloudflare so that requests to example.com/another-application/ go to a different server.

Please see the above comment. rewriting the HOST header is only possible with the enterprise plan to prevent abuse of 3rd-party services.

Cloudflare only offers direct reverse proxy functionality, eg example.com/a -> example.com/a and you can’t customize the proxy_pass directives. You will need to keep your current server config if you want a subdirectory to be served from a different host.

3 Likes

You could the thing you want using Workers, you would need to implement the proxy yourself, but it isn’t that difficult…

1 Like

This topic was automatically closed after 31 days. New replies are no longer allowed.