Urgent.News

What's breaking now, across thousands of outlets.

Tech

Path-Based Routing with Reverse Proxy: Serving Multiple Websites from One Domain

Hey developers ๐Ÿ‘‹ At some point in our development journey, weโ€™ve all played around with domains, subdomains, routes, reverse proxies, and enough DNS records to make us question our life choices. But hereโ€™s an interesting problem: What if you want a completely different website to appear at a specific path of your existing domain? Let's say I have a pastry business called My Pastries ๐Ÿฐ. My mainโ€ฆ

Hey developers ๐Ÿ‘‹ In our development journey, we've all experimented with domains, subdomains, routes, reverse proxies, and numerous DNS records. However, there's an intriguing issue: what if you'd like a distinct website to display at a particular path of your existing domain? Imagine I have a pastry business called My Pastries ๐Ÿฐ.

My principal website is located at mypastries.com, which is built with Next.js for server-side rendering, outstanding performance, robust SEO, and ample flexibility to customize everything. Everything is going smoothly. Then, I decide to establish a blog. Not only is this because everyone constantly says content is king, but also because I wish to publish useful content, establish topical authority, attract organic traffic, and provide the website with additional reasons to exist beyond merely showcasing our cakes. So, I deploy this blog separately. My infrastructure now resembles:

172.1.0.1 โ†’ Main Next.js website

172.1.0.2 โ†’ WordPress/CMS blog

But here's the interesting part. I don't want users to visit blog.mypastries.com; instead, I want them to visit mypastries.com/blog. If they open an article, like mypastries.com/blog/how-to-make-the-perfect-croissant, I want the second server to manage that request. Yet, I still want the browser to display mypastries.com/blog/how-to-make-the-perfect-croissant without any redirects, separate domains, or making users aware of the blog's actual hosting location.

This is where reverse proxies and path-based routing come into play. Here's how to serve two completely different servers as one website using reverse proxies and path-based routing.

Written by urgent.news from Dev.to's reporting โ€” not their text. Machine-written โ€” may contain errors; check the original before relying on it.

Read the original at dev.to โ†’

More in Tech

Why your OpenGraph tags break on LinkedIn (and how to actually fix it)

Last week someone asked me why their React app showed an empty card when shared on LinkedIn, even though their tags were right there in the code.

  • LinkedIn scrapers don't execute client-side JavaScript, leading to empty cards
  • Meta tags injected post-client-side hydration, missing by the time crawler finishes
  • ogcraft.dev offers HTML visualizer and crawl-back image engine for LinkedIn optimization

What I learned checking 65 client domains with RDAP instead of WHOIS

I built a domain expiry monitor, and to test it against something other than my own domains I pointed it at the "our work" pages of 30 US web design agencies โ€” the client sites they link to publiclyโ€ฆ

  • RDAP provided structured JSON responses over HTTPS, unlike WHOIS's plain text
  • Registrar names hidden in jCard format, unlike WHOIS's straightforward display
  • IANA's bootstrap incomplete, leading to misdated public suffix expirations

More from Saturday 12 September โ†’