Use Cloudflare Pages Functions as a reverse proxy with custom domain support.

Overview

cf-page-func-proxy

Use Cloudflare Pages Functions as a reverse proxy with custom domain support.

Getting Start

1.下载或是Fork本仓库

2.修改_worker.js中的url.hostname为你需要反代的网址

url.hostname="example.com";

3.打开Cloudflare Dashboard,进入Pages管理页面,选择创建项目,如果在第一步中选择的是fork本仓库,则选择1Connect to Git,如果第一步中选择的是下载本仓库则选择2Direct Upload 1

绑定自定义域名

1.进入Cloudflare Pages管理页面,选择刚刚创建的Pages项目,点击名称进入项目设置页面 2

2.选择页面中的自定义域 3

3.选择设置自定义域 4

4.在页面中输入需要绑定的域名,并点击继续,这里的域名可以是子域名 5

5.在设置方法中选择开始cname设置 6

6.按照页面给出的说明去DNS服务提供商处修改DNS解析记录,即可完成自定义域名绑定 7

You might also like...

Connect to a Postgres database from a Cloudflare Worker, using Cloudflare Tunnel

Cloudflare Workers Postgres Client This is an experimental module. Heavily based on cloudflare/worker-template-postgres, but cleaned up and bundled in

Dec 22, 2022

A Cloudflare Workers service that fetches and renders Notion pages as HTML, Markdown, or JSON.

notion-fetch A Cloudflare Workers service that fetches and renders Notion pages as HTML, Markdown, or JSON. Powered by Durable Objects and R2. Usage P

Jan 6, 2023

A CloudFlare Worker / script / bot to sync Notion pages publicly as GitHub Discussions.

A CloudFlare Worker / script / bot to sync Notion pages publicly as GitHub Discussions.

notion-github-sync This bot syncs public Notion pages as GitHub Discussions/Issues. It's done periodically, based on the pages shared with the Notion

Dec 22, 2022

Running Next.js on Cloudflare Pages.

Nextflare - Run Next.js Edge Runtime on Cloudflare Pages (Workers) NOTE: We're still actively updating this repository, docs, and preparing a potentia

Jan 3, 2023

Example of a Cloudflare Pages server side rendering (SSR) project powered by Hono.

Hono SSR on Cloudflare Pages Example of a Cloudflare Pages server side rendered (SSR) project powered by Hono. This project demonstrates: Accessing en

Nov 19, 2022

Remix run stack built for the edge (cloudflare pages and d1)

Remix run stack built for the edge (cloudflare pages and d1)

Remix Race Stack Learn more about Remix Stacks. npx create-remix@latest --template jose-donato/race-stack What's in the stack Cloudflare Pages for ho

Aug 10, 2023

Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Nov 2, 2022

Seamlessly connect your web server to Rebrandly so that you can re-use your domain name for both your app and your short links

rebrandly-express Seamlessly connect your web server to Rebrandly so that you can re-use your domain name for both your app and your short links Rebra

Dec 13, 2022

Functions Recipes is a library of examples to help you getting started with Salesforce Functions and get used to their main features.

Functions Recipes is a library of examples to help you getting started with Salesforce Functions and get used to their main features.

Functions Recipes Introduction Salesforce Functions lets you use the Salesforce Platform for building event-driven, elastically scalable apps and expe

Dec 29, 2022
Comments
  • 如果需要使用单双日实现访问不同的域名,这样做可以吗

    如果需要使用单双日实现访问不同的域名,这样做可以吗

    RT

    代码如下:

    const day1 = 'app0.herokuapp.com'
    const day2 = 'app1.herokuapp.com'
    
    export default {
        async fetch(request, env) {
          let url = new URL(request.url)
          if (url.pathname.startsWith("/")) {
            let day = new Date().getDay()
            if (day === 0) {
              host = day1
            } else {
              host = day2
            }
            url.hostname=host
            let response = new Response(url, request)
            return response(new_request)
          }
          return env.ASSETS.fetch(request);
        }
      };
    
    opened by ghost 1
  • 请教pages执行原来workers代码的问题

    请教pages执行原来workers代码的问题

    下面是在workers验证过可以执行的代码,用于获取用户真实IP的脚本源码,目的是用户访问这个workers的网址就可以报告用户端的出口ip地址

    addEventListener("fetch", (event) => { event.respondWith( handleRequest(event.request).catch( (err) => new Response(err.stack, { status: 500 }) ) ); });

    /**

    • Return user real ip as response in plain text.
    • @param {Request} request
    • @returns {Promise} */ async function handleRequest(request) { const clientIP = request.headers.get("CF-Connecting-IP") return new Response(clientIP); }

    但是上面这段代码按照你这个项目的方法,替代了_worker.js文件里面的所有代码成为上面的代码,在pages上一部署就报告错误,我由于对这些代码不熟悉,能否麻烦你帮忙看看是否在pages上部署要做相应的代码更改?

    非常感谢!

    opened by egg1234 0
  • 多台服务器负载均衡方法

    多台服务器负载均衡方法

    export default {
    	async fetch(request, env) {
    		const cars = [
    			"app1.example.com", 
    			"app2.example.com", 
    			"app3.example.com", 
    			"app4.example.com", 
    			"app5.example.com"
    		];
    		let host = cars[Math.floor(Math.random() * cars.length)];	//随机选择VPS
    		//let host = cars[new Date().getDate() % cars.length];		//每天自动更换VPS
    		
    		let url = new URL(request.url);
    		if (url.pathname.startsWith('/')) {
    			url.hostname = host;
    			let new_request = new Request(url,request);
    			return fetch(new_request);
    		}
    		return env.ASSETS.fetch(request);
    	}
    };
    
    opened by skydevil88 1
Owner
null
Zemi is data-driven and reverse-routing library for Express. It provides out-of-the-box OpenAPI support, allowing you to specify and autogenerate an OpenAPI spec.

zemi zemi is a data-driven routing library for Express, built with Typescript. Features: optional, out-of-the-box support for OpenAPI reverse-routing

Yoaquim Cintrón 5 Jul 23, 2022
A set of useful helper methods for writing functions to handle Cloudflare Pub/Sub messages (https://developers.cloudflare.com/pub-sub/)

pubsub A set of useful helper methods for writing functions to handle Cloudflare Pub/Sub messages. This includes: A isValidBrokerRequest helper for au

Cloudflare 18 Dec 4, 2022
Functional-style Cloudflare Durable Objects with direct API calls from Cloudflare Workers and TypeScript support.

durable-apis Simplifies usage of Cloudflare Durable Objects, allowing a functional programming style or class style, lightweight object definitions, a

Dabble 12 Jan 2, 2023
proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy ?? yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

4D/ҵ.com Dashboards 13 Dec 30, 2022
Proxy but misspelled -- closed proxy for the internet

pyrox Proxy that runs on Cloudflare Workers. Setup Install wrangler2. npm install wrangler. Generate a public Ed25519 key, exported under SPKI mode wi

bots.gg 10 Sep 9, 2022
Kuldeep 2 Jun 21, 2022
serverless plugin to setup custom domain for lambdas deployed with function url.

serverless-aws-function-url-custom-domain Automatically creates AWS CloudFront distribution and Route 53 records to AWS Lambda with Function URL (no a

Sha 8 Nov 27, 2022
基于 gh-proxy + Jsdelivr+ cnpmjs + cloudflare workers 的 GitHub Serverless API 工具。

better-github-api Better, Eazy, Access Anywhere 介绍 基于 gh-proxy + Jsdelivr + cnpmjs + cloudflare workers 的 GitHub Serverless API 工具。 cdn.js:仅含 gh-proxy

One Studio 11 Nov 23, 2022
Experimental proxy and wrapper for safely embedding Web Archives (warc.gz, wacz) into web pages.

warc-embed-netlify ??️ Experimental proxy and wrapper for safely embedding Web Archives (.warc.gz, .wacz) into web pages. This particular implementati

Harvard Library Innovation Laboratory 6 Sep 1, 2022
This package support to build a complex application with domain driven design.

The library implement Domain Driven Design for Nodejs base on Typescript. Description This package support to build a complex application with th doma

null 11 Nov 7, 2022