NGINX reverse proxy to Cloudflare Pages returns 403 Forbidden

I am encountering an issue where I receive a “403 Forbidden” error when trying to access my Cloudflare Pages application through a reverse proxy.

The reason I need a proxy is because our main site are hosted on Fly but the Documentation site (Docusaurus) is hosted on Cloudflare Pages and we want to serve the Documentation site under the root domain as

The following is the example of the proxy conf

location /docs {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $http_host;
    set $backend "";
    proxy_pass $backend;
   proxy_ssl_server_name on;

Could anyone advice if there is missing header specifically for Cloudflare Pages hosted site?

Note that I was able to proxy to a Discourse forum with additional 2 headers as following:

# A cdck-trust-proxy header with a specific value must be sent with every request
proxy_set_header cdck-trust-proxy xxxxxx;
# Proxy pass to Discourse upstream server. Use variable for resolver to honor DNS changes for upstream proxies
set $backend "";

Thanks in advance,

In case someone saw this thread, here is the working conf

server {
  listen 8080;
  proxy_ssl_server_name on;
  proxy_ssl_name $proxy_host;

  location /doc/ {
    proxy_set_header Host "";
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

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