I mean all those landing pages, legal, promo materials etc.
Yes, you can point domain.com -> netlify, while app.domain.com -> your frontend server.
But what if you need a bit more than that? Like use auth cookies, expose some web-app features, urls on root domain etc.
How do you combine all that with the rest of static pages' you want to keep updating at runtime without managing own CMS?
Any tools, libs, best practices?
You just put the whole thing behind an nginx (which it likely already is), and have it serve up the static content from a local filesystem, while routing your dynamic stuff however needed.
This lets me host my marketing pages as static pages, and the app pages at /app - works really well, no messing around with separate builds, would highly recommend it.
For reverse proxy you can go the old and trusted route with e.g. Nginx, go fully managed with something like external rewrites on Vercel, or even hack together your own thing with edge workers.
For all from one system, whatever you're using for your backend, be it React (with Next.js) or Ruby on Rails, can probably also serve any kind of static content, but it might not be worth intermingling that based on your situation.
My personal favorite pattern with HTTP is using nginx as the DNS endpoint for several hosts (root_domain, api.root_domain, tool.root_domain etc).
Nginx will forward traffic based on the HTTP Host header in any given correctly formed HTTP request. This also works well for a load balancer. I think the hip thing for today's market is itsio? Same basic idea.
Another benefit of an application layer proxy is you can do application layer things, like telling a client to redirect from http to https and serving https using let's encrypt. Privacy for free (state actor caveats apply).
Your applications (then one behind nginx) do not need to use transit layer encryption (unless of course they're connected to nginx via untrusted networks, be sensible) which is a huge boost because nginx do a good job implementing all of that logic for you and it's nice to hand off responsibility to trusted entities that do the job well.
Unless it's log4j, apparently.
I think when deciding to create this kind of architecture we should put in balance:
On one side:
- What do we gain from this: probably marketing/sales/UX and how much value this kind of architecture will create
On another side:
- The cost to implement this
+
- The cost to manage the complexity created by implementing this architecture
+
- The reduction of development speed due to coupling
[1]: http://sgmljs.net