{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["img"]},"type":"markdown"},"seo":{"title":"Setting up a Reverse Proxy in Cloudflare","description":"Integrate and automate your content creation process with Foleon's powerful API.","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"setting-up-a-reverse-proxy-in-cloudflare","__idx":0},"children":["Setting up a Reverse Proxy in Cloudflare"]},{"$$mdtype":"Tag","name":"div","attributes":{"style":{"padding":"1em","backgroundColor":"#fff3cd","borderLeft":"5px solid #ffeeba","margin":"1em 0"}},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["⚠️ Warning:"]}," This guide provides a general overview of the configuration process. Technical requirements vary by environment; always consult your internal IT or security teams before applying these settings. If you would like to complete this setup with a Foleon technical expert, please contact ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Foleon Support"]}," or your ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Customer Success Manager."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-adding-your-domain-into-foleon","__idx":1},"children":["1. Adding your domain into Foleon"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["login to Foleon"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["go to \"Domains\" in the Admin Console (or your workspace)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use HTTPS protocol to ensure End to End encryption"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click \"Create new Domain\""]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Fill in the domain"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click the checkbox for reverse proxy"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["(optional) enter your certificate details"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click \"save\""]}]},{"$$mdtype":"Tag","name":"Image","attributes":{"src":"/assets/domains.3b86bffae10ff009a14daf55021f0e6bac24bc78dff6fe695f1202d24a89f377.9c1bb791.gif","alt":"domains.gif","withLightbox":true,"width":"","height":""},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-creating-a-worker-in-cloudflare","__idx":2},"children":["2. Creating a worker in Cloudflare"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["We will create a small background script (Worker) that invisibly retrieves content from Foleon when a user visits your chosen path."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Log in to your Cloudflare Dashboard."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In the left sidebar, click \"Workers & Pages\"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click the blue \"Create Application\" button."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click \"Create Worker\"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Name the worker foleon-proxy (or similar) and click \"Deploy\"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click \"Edit Code\"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Delete all existing code in the left-hand editor and paste the code block below exactly as is:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"export default {\n  async fetch(request, env) {\n    const sourceUrl = new URL(request.url);\n    const targetOrigin = env.FOLEON_TARGET; // \"https://s1.us.foleon.com\" OR \"https://s1.foleon.com\"\n    const targetUrl = new URL(`${sourceUrl.pathname}${sourceUrl.search}`, targetOrigin);\n    \n    const forwardedHost = env.PUBLIC_HOST || sourceUrl.hostname;\n    \n    const newHeaders = new Headers(request.headers);\n    newHeaders.set(\"X-Forwarded-Host\", forwardedHost);\n    newHeaders.set(\"X-Forwarded-Proto\", \"https\");\n\n    const newRequest = new Request(targetUrl, {\n      method: request.method,\n      headers: newHeaders,\n      body: request.body,\n      redirect: \"manual\"\n    });\n\n    try {\n      return await fetch(newRequest);\n    } catch (e) {\n      return new Response(\"Proxy Error: \" + e.message, { status: 502 });\n    }\n  }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"3-configuring-the-worker","__idx":3},"children":["3. Configuring the worker"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By default, the script works automatically. However, you can add Environment Variables if you need to override the host (e.g., if you are testing on a staging URL but want to load production content)."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go back to the Worker overview page (click the < arrow in the top left)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go to the Settings tab > Variables."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Under Environment Variables, click Add Variable to set the following:"]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Variable Name"},"children":["Variable Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value Example"},"children":["Value Example"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["PUBLIC_HOST"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["yourdomain.com"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["(Optional)"]}," Forces a specific domain to be sent to Foleon. Useful if testing on workers.dev URLs."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["FOLEON_TARGET"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://s1.foleon.com"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["REQUIRED"]}," Change the destination server.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"US: https://s1.us.foleon.com",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"EU: https://s1.foleon.com"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"4-routing-traffic-to-the-worker","__idx":4},"children":["4. Routing Traffic to the Worker"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Now we need to tell Cloudflare to use this script only for your specific folder (e.g., /publications/), leaving the rest of your site untouched."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go back to the \"Workers & Pages\" dashboard and click on your new \"foleon-proxy\" worker (or what you've called the worker)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click the Settings tab near the top."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Add a domain under section \"Domains & Routes\""]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Choose \"Route\""]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Zone: Select your main domain (e.g., yourdomain.com)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Route: Enter the path you want to use followed by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/*"]},".",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Example: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["yourdomain.com/publications/*"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["IMPORTANT"]},": Ensure you include the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["www."]}," if your site uses it."]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click Add Route."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"5-apply-a-domain-to-a-project","__idx":5},"children":["5. Apply a domain to a project"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Login to foleon."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Go to project settings."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Select the newly created domain."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Setup the basepath / subfolder you want to use to publish your documents on."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Make sure to publish a document in this project."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can setup multiple projects with the same basepath."," ","e.q. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/en/guide/finance/"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/en/guide/legal/"]}]}]},"headings":[{"value":"Setting up a Reverse Proxy in Cloudflare","id":"setting-up-a-reverse-proxy-in-cloudflare","depth":1},{"value":"1. Adding your domain into Foleon","id":"1-adding-your-domain-into-foleon","depth":2},{"value":"2. Creating a worker in Cloudflare","id":"2-creating-a-worker-in-cloudflare","depth":2},{"value":"3. Configuring the worker","id":"3-configuring-the-worker","depth":2},{"value":"4. Routing Traffic to the Worker","id":"4-routing-traffic-to-the-worker","depth":2},{"value":"5. Apply a domain to a project","id":"5-apply-a-domain-to-a-project","depth":2}],"frontmatter":{"seo":{"title":"Setting up a Reverse Proxy in Cloudflare"}},"lastModified":"2026-03-31T14:06:01.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/reverse_proxy/cloudflare","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}