How to proxy a cloudflare hosted pages app to show on my subdomain which is managed by nginx?

I have a cloudflare pages app, let's call it dashboard.pages.dev. I am using nginx as my reverse proxy. Let's say my main server where nginx is running and managing requests is accessible on the domain example.com. I want to access my pages app on a subdomain of example.com . How do i do that? I am using the following configuration for the pages app like so:
1 Reply
YoYo
YoYoOP2mo ago
server {
listen 80;
server_name app.example.com;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name app.example.com;

# SSL for the app subdomain
ssl_certificate /ssl/cert.pem;
ssl_certificate_key /ssl/cert.key;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;

location / {
# Forward to Cloudflare-hosted app
proxy_pass http://<my-pages-app-url>.pages.dev;

# Set headers for forwarded requests
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Use resolver with IPv6 disabled for Cloudflare
# resolver 1.1.1.1 ipv6=off;

# If using Cloudflare, it's a good idea to trust the Cloudflare origin IPs
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
real_ip_header CF-Connecting-IP;
}
}
server {
listen 80;
server_name app.example.com;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name app.example.com;

# SSL for the app subdomain
ssl_certificate /ssl/cert.pem;
ssl_certificate_key /ssl/cert.key;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;

location / {
# Forward to Cloudflare-hosted app
proxy_pass http://<my-pages-app-url>.pages.dev;

# Set headers for forwarded requests
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Use resolver with IPv6 disabled for Cloudflare
# resolver 1.1.1.1 ipv6=off;

# If using Cloudflare, it's a good idea to trust the Cloudflare origin IPs
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
real_ip_header CF-Connecting-IP;
}
}
What am i doing wrong here that I am unable to access my app. I am getting the "ORIGIN DNS ERROR" page as the result
Want results from more Discord servers?
Add your server