Setting Up Hostnames for Multi-Tenant Sites in Oqtane

Setting Up Hostnames for Multi-Tenant Sites in Oqtane

OK, so it’s time for a new article about Oqtane!

In my previous post (or “mental note,” as I like to call them), I covered how to set up
multi-tenancy in Oqtane. Today, I got a really nice surprise —
Shaun Walker just posted an excellent video explaining how multi-tenancy works,
along with its advantages and possible drawbacks.

From my point of view, the advantages clearly outweigh the disadvantages,
although it depends on your specific scenario.


Extending the Previous Example

I wanted to improve my previous example a bit. So, I created a new GitHub repository using the same base code,
but this time I added hostnames for each tenant.

A hostname is basically the domain that points to one of your tenants in Oqtane.
In a typical setup, you use DNS records for this.
The simplest case is an A record that points to a specific IP address.

When a request arrives, the server reads the hostname from the request and routes it to the correct tenant.

This part isn’t specific to Oqtane — it’s how web servers work in general.
The concept exists in IIS, Apache, and NGINX,
and it’s part of basic networking theory. If you want to learn more,
there are countless articles about how DNS works.


A Small Story from the Past

This actually takes me back — one of the first things I learned as a teenager was how to configure DNS
and run my own Apache web server.

I even started offering web hosting from my home using an old 486 computer (yes, really).
Eventually, my internet provider noticed what I was doing, blocked my connection, and called my parents.
Let’s just say… that Christmas was canceled for me. 😅
Anyway, that’s a story for another time.


Setting Up Local Domains for Tenants

For today’s example, I’m using the same structure as before:

  • One host site
  • Two tenant sites: MyCompany1 and MyCompany2

I want to show you how to assign domain names to each of them.

If you’re running everything locally (for example, through Visual Studio or VS Code),
you can’t use real domain names — but you can simulate them using the Windows hosts file.

If you’ve ever wondered how your computer resolves localhost to 127.0.0.1,
the answer lies in that file. It’s located inside the Windows system folder,
and it maps domain names to IP addresses.

Here’s the cool part: you can add your own domains there, pointing them to any IP you like.
It’s a great trick for local testing.

Below, you’ll see a screenshot of my hosts file.
I’ve mapped my fake domains to my local IP address,
so when I open them in the browser, the requests go straight to my
Kestrel server, which then routes them to the correct tenant.


How to Edit the Windows Hosts File

Editing the hosts file in Windows is simple, but you need administrative permissions.
Here’s how you can do it safely:

  1. Press Start, type Notepad, then right-click it and select
    Run as administrator.
  2. Once Notepad opens, go to File → Open and browse to:
    C:\Windows\System32\drivers\etc\hosts
  3. In the open dialog, change the filter from “Text Documents (*.txt)” to “All Files (*.*)”
    so you can see the hosts file.
  4. Add your entries at the bottom of the file. For example:
    127.0.0.1   mycompany1.xyz
    127.0.0.1   mycompany2.xyz
    

    Each line maps an IP address to a domain name.

  5. Save the file and close Notepad.
  6. Open your browser and visit http://mycompany1.xyz:44398
    (or the port your Oqtane app is running on).
    You should see the tenant corresponding to that domain.

⚠️ Important: If you edit the file without admin rights,
you won’t be able to save it. Also, be careful — if you modify or delete system entries by accident,
your network resolution might stop working.

Here is how my host file actually looks at the moment

 

Set siteURL for :Company 1

Set siteURL for :Company 2

 

Testing with Real Domains

Of course, this same logic applies to real domains too — as long as your Oqtane instance is publicly accessible.

In one of the next parts (maybe part 3 or 4), I’ll show how to configure it using a web server like
Apache. I know that NGINX is more popular these days,
but I’ve used Apache since my teenage years, so I’m more comfortable with it.

Still, I’ll probably demonstrate both.

Most developers today use cloud providers like AWS or Azure,
but honestly, I still prefer spinning up a simple Ubuntu server and doing everything manually.
The best tool is the one you know best — and for me, that’s Apache on Ubuntu.


Demo

As you can see there is a little bit of a different behavior if is a default site or not If it’s a default site it will redirect to that URL if not it’s going to redirect to the default site URL

 

Resources

  • 🧩 GitHub Repository — This project is based on the previous example
    but adds hostname configuration and uses SQLite for simplicity.

egarim/DomainNames

  • 🎥 Shaun Walker’s Video on Multi-Tenancy
    Highly recommended if you want a solid overview of how it all works:


 

Embrace the Dogfood: How Dogfooding Can Transform Your Software Development Process

Embrace the Dogfood: How Dogfooding Can Transform Your Software Development Process

Hey there, fellow developers! Today, let’s talk about a practice that can revolutionize the way we create, test, and perfect our software: dogfooding. If you’re wondering what dogfooding means, don’t worry, it’s not about what you feed your pets. In the tech world, “eating your own dog food” means using the software you develop in your day-to-day operations. Let’s dive into how this can be a game-changer for us.

Why Should We Dogfood?

  • Catch Bugs Early: By using our own software, we become our first line of defense against bugs and glitches. Real-world usage uncovers issues that might slip through traditional testing. We get to identify and fix these problems before they ever reach our users.
  • Enhance Quality Assurance: There’s no better way to ensure our software meets high standards than by relying on it ourselves. When our own work depends on our product, we naturally aim for higher quality and reliability.
  • Improve User Experience: When we step into the shoes of our users, we experience firsthand what works well and what doesn’t. This unique perspective allows us to design more intuitive and user-friendly software.
  • Create a Rapid Feedback Loop: Using our software internally means continuous and immediate feedback. This quick loop helps us iterate faster, refining features and squashing bugs swiftly.
  • Build Credibility and Trust: When we show confidence in our software by using it ourselves, it sends a strong message to our users. It demonstrates that we believe in what we’ve created, enhancing our credibility and trustworthiness.

Real-World Examples

  • Microsoft: They’re known for using early versions of Windows and Office within their own teams. This practice helps them catch issues early and improve their products before public release.
  • Google: Googlers use beta versions of products like Gmail and Chrome. This internal testing helps them refine their offerings based on real-world use.
  • Slack: Slack’s team relies on Slack for communication, constantly testing and improving the platform from the inside.

How to Start Dogfooding

  • Integrate it Into Daily Work: Start by using your software for internal tasks. Whether it’s a project management tool, a communication app, or a new feature, make it part of your team’s daily routine.
  • Encourage Team Participation: Get everyone on board. The more diverse the users, the more varied the feedback. Encourage your team to report bugs, suggest improvements, and share their experiences.
  • Set Up Feedback Channels: Create dedicated channels for feedback. This could be as simple as a Slack channel or a more structured feedback form. Ensure that the feedback loop is easy and accessible.
  • Iterate Quickly: Use the feedback to make quick improvements. Prioritize issues that affect usability and functionality. Show your team that their feedback is valued and acted upon.

Overcoming Challenges

  • Avoid Bias: While familiarity is great, it can also lead to bias. Pair internal testing with external beta testers to get a well-rounded perspective.
  • Manage Resources: Smaller teams might find it challenging to allocate resources for internal use. Start small and gradually integrate more aspects of your software into daily use.
  • Consider Diverse Use Cases: Remember, your internal environment might not replicate all the conditions your users face. Keep an eye on diverse scenarios and edge cases.

Conclusion

Dogfooding is more than just a quirky industry term. It’s a powerful practice that can elevate the quality of our software, speed up our development cycles, and build stronger trust with our users. By using our software as our customers do, we gain invaluable insights that can lead to better, more reliable products. So, let’s embrace the dogfood, turn our critical eye inward, and create software that we’re not just proud of but genuinely rely on. Happy coding, and happy dogfooding! ??

Feel free to share your dogfooding experiences in the comments below. Let’s learn from each other and continue to improve our craft together!