YoYo
YoYo
CDCloudflare Developers
Created by YoYo on 11/3/2024 in #general-help
How do I route cloudflare pages through my nginx proxy which is hosted locally using cloudflared?
# App dashboard server block for both http and https
server {
listen 80;
server_name app.${SERVER_NAME};
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name app.${SERVER_NAME};

# SSL for the app subdomain (if using Full (Strict) SSL with Cloudflare)
ssl_certificate ${SSL_CERT_PATH};
ssl_certificate_key ${SSL_KEY_PATH};

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

location / {
# Forward to Cloudflare-hosted app
proxy_pass https://${CLOUDFLARE_DASHBOARD_URL};
proxy_ssl_server_name on;
proxy_ssl_name $proxy_host;

# Set headers for forwarded requests
proxy_set_header Host https://${CLOUDFLARE_DASHBOARD_URL};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

}
# App dashboard server block for both http and https
server {
listen 80;
server_name app.${SERVER_NAME};
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name app.${SERVER_NAME};

# SSL for the app subdomain (if using Full (Strict) SSL with Cloudflare)
ssl_certificate ${SSL_CERT_PATH};
ssl_certificate_key ${SSL_KEY_PATH};

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

location / {
# Forward to Cloudflare-hosted app
proxy_pass https://${CLOUDFLARE_DASHBOARD_URL};
proxy_ssl_server_name on;
proxy_ssl_name $proxy_host;

# Set headers for forwarded requests
proxy_set_header Host https://${CLOUDFLARE_DASHBOARD_URL};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

}
3 replies
CDCloudflare Developers
Created by YoYo on 11/3/2024 in #general-help
How do I route cloudflare pages through my nginx proxy which is hosted locally using cloudflared?
Here is the nginx config template that I am using:
events {
}

http {
upstream backend_api {
server ${BACKEND_API_HOST}:${BACKEND_API_PORT};
}

upstream search_engine {
server ${SEARCH_ENGINE_HOST}:${SEARCH_ENGINE_PORT};
}

# Backend api server block for both http and https
server {
listen 80;
server_name api.${SERVER_NAME};
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name api.${SERVER_NAME};

ssl_certificate ${SSL_CERT_PATH};
ssl_certificate_key ${SSL_KEY_PATH};

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

location /static/ {
alias ${STATIC_FILES_FOLDER};
include mime.types;
access_log off;
expires 30d;
}

location / {
proxy_pass http://backend_api;
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;
}
}

# Search api server block for both http and https
server {
listen 80;
server_name search.${SERVER_NAME};
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name search.${SERVER_NAME};

ssl_certificate ${SSL_CERT_PATH};
ssl_certificate_key ${SSL_KEY_PATH};

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

location / {
proxy_pass http://search_engine;
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;
}
}
events {
}

http {
upstream backend_api {
server ${BACKEND_API_HOST}:${BACKEND_API_PORT};
}

upstream search_engine {
server ${SEARCH_ENGINE_HOST}:${SEARCH_ENGINE_PORT};
}

# Backend api server block for both http and https
server {
listen 80;
server_name api.${SERVER_NAME};
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name api.${SERVER_NAME};

ssl_certificate ${SSL_CERT_PATH};
ssl_certificate_key ${SSL_KEY_PATH};

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

location /static/ {
alias ${STATIC_FILES_FOLDER};
include mime.types;
access_log off;
expires 30d;
}

location / {
proxy_pass http://backend_api;
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;
}
}

# Search api server block for both http and https
server {
listen 80;
server_name search.${SERVER_NAME};
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name search.${SERVER_NAME};

ssl_certificate ${SSL_CERT_PATH};
ssl_certificate_key ${SSL_KEY_PATH};

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

location / {
proxy_pass http://search_engine;
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;
}
}
3 replies
CDCloudflare Developers
Created by YoYo on 11/2/2024 in #pages-help
How to proxy a cloudflare hosted pages app to show on my subdomain which is managed by nginx?
I am getting the "ORIGIN DNS ERROR" page as the result
4 replies
CDCloudflare Developers
Created by YoYo on 11/2/2024 in #pages-help
How to proxy a cloudflare hosted pages app to show on my subdomain which is managed by nginx?
What am i doing wrong here that I am unable to access my app.
4 replies
CDCloudflare Developers
Created by YoYo on 11/2/2024 in #pages-help
How to proxy a cloudflare hosted pages app to show on my subdomain which is managed by nginx?
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;
}
}
4 replies
CDCloudflare Developers
Created by YoYo on 8/24/2024 in #workers-help
How to deploy next app using cloudflare workers?
Thanks for the help
10 replies
CDCloudflare Developers
Created by YoYo on 8/24/2024 in #workers-help
How to deploy next app using cloudflare workers?
Ah, it worked. I thought the DNS changes are instant, it took a while but I can see it now.
10 replies
CDCloudflare Developers
Created by YoYo on 8/24/2024 in #workers-help
How to deploy next app using cloudflare workers?
I did wrangler pages deploy and the deployment has been created and I can see it in the cf dashboard as well but when I am visiting the link now, it is showing This site can’t be reached chrome page. This is my wrangler toml file for pages:
name = "dashboard"
type = "javascript" # or "module" if you are using the modules syntax


compatibility_date = "2024-08-24"
compatibility_flags = [ "nodejs_compat" ]

# If your project uses any environment variables, you can define them here.
# [env.production]
# VAR_NAME = "value"


pages_build_output_dir = ".vercel/output/static"
name = "dashboard"
type = "javascript" # or "module" if you are using the modules syntax


compatibility_date = "2024-08-24"
compatibility_flags = [ "nodejs_compat" ]

# If your project uses any environment variables, you can define them here.
# [env.production]
# VAR_NAME = "value"


pages_build_output_dir = ".vercel/output/static"
What am i doing wrong?
10 replies
CDCloudflare Developers
Created by YoYo on 8/24/2024 in #workers-help
How to deploy next app using cloudflare workers?
Yes, that's exactly what I was asking. Also, is there a need to have wrangler toml as well or i need to configure it by going to the cf dashboard?
10 replies
CDCloudflare Developers
Created by YoYo on 8/24/2024 in #workers-help
How to deploy next app using cloudflare workers?
If i do wrangler pages deploy, the build is going to be created locally first right?
10 replies