Setup docs site in Subdirectory of Existing Static Website
I am following an older blog and using a worker to redirect traffic from a subdirectory on one pages site to another pages site.
The route I have in place doesn't get triggered. Should I be using functions instead?
https://qoyyimafiassalam.medium.com/reverse-proxy-with-cloudflare-workers-setup-blog-in-subdirectory-of-existing-static-website-96e4d186d4f0
Medium
Reverse Proxy with Cloudflare Workers: Setup Blog in Subdirectory o...
Blog is an essential part to increase your site’s traffic, authority, and search-engine-related performance. With blog, you can inform…
21 Replies
i created a feature request: https://community.cloudflare.com/t/deploying-pages-sites-to-subdirectories/496408
Cloudflare Community
Deploying pages sites to subdirectories
Based on the discussion on this thread, I would like to formally request the feature to set up a pages site under a subdirectory or route on an existing zone domain. This would also mean nesting multiple pages sites under one domain could be possible. One real example would be a root marketing site, /blogs rendered by JAMstack framework, /docs b...
Why not just merge those multiple projects into a single one?
They are being generated by separate static site generation tools.
And are managed in different repositories.
And SEO isn't good at different subdomains yet... Unfortunately.
You could have a GH action that, on an update to either repo, clones both, builds both, and then uploads a single Pages project
Yes we could but we are already doing that for managing multiple versions of our docs https://github.com/vordimous/zilla-docs/blob/develop/.github/workflows/build-deploy-docs.yml#L53 .
It would also mean centralized builds for projects in a different repo which wasn't an ideal plan.
You could also utilize an external CI/CD system if you have one, but yeah. The current Pages CI isn’t ideal for this kind of site, and tbh, I’m not 100% sure if/how they plan on improving it
So far I have a worker that can route but it looks like I will need an active zone domain to do it.
You could use a function?
I am using github to build and push the static site which does help. the Pages CI would not handle all of these gymnastics!
ok is that better than a worker? I was trying to use one or the other but can't tell which is designed for proxy style route handling?
Functions are basically just Workers on Pages
my understanding is worker->routing and functions->mock apis
They come with some Pages sugar(tied to deployments, built-in router), but they are still Workers under the hood
In fact, Pages itself is a Worker too
ok so this is currently working in a Worker and rendering the underlying pages content
There will be a pages site at root (/) of my domain so i could just manage this code as a function on that pages site?
This root pages site is also where I am managing robots.txt and sitmaps and such
Give me a second, and I'll rewrite it. Just wondering though, do you know if the GH Actions cache applies across different repositories?
Unfortunately, it does not. It doesn't even persist across branches!!!! It is a good thought and one I have tried.
This whole experience will be a blog post in my future i think 😬
Might be slightly hackier, but you could cache the build output in R2?
I just remembered, you can also just rename that file to
_worker.js
, and put it in the output directory of your Pages project.This is my last resort plan 😬
oh cool Ill try this out and see what i can get to work. Thank you for all of the help!!
@HardAtWork https://aklivity-docs.pages.dev/zilla/next
Zilla Docs
Home
Zilla is open-source software connecting web and mobile applications to event-driven microservices using standard protocols, such as HTTP, Server-Sent Events and Kafka. Zilla is...
nice even the card works
I am using this with a local
_redirects
file as well.
Also a the generic worker I added yesterday with a route of docs-portal.pages.dev/*
started working today randomly so that is a viable option.
However, I like the _worker.js
option better since it keeps everything in one place.the third pages site being served: https://docs-portal.pages.dev/msk-proxies/next/
Amazon MSK Proxies
Home
Help & Support If you have any questions or run into bugs or issues, reach out on the Aklivity Community Slack Workspace (https://join.slack.com/t/aklivitycommunity/shared\_invi...
updated worker code: