How does one go about allowing custom domains to point to your application?

twitter logo github logo ・1 min read

I've been mulling over a web application idea and was wondering how does one go about allowing users to set up custom domains to point to their said profile/account on the application?

For example, folks can set up a custom domain or subdomain to point to their Medium account.

I haven't thought through the entire stack yet, but let's say it's either Rails hosted on Heroku or AWS using a static site set up. Is this feasible and how would one go about setting this up?

Update I've provided a crude example of what I'd hope to achieve in this comment below.

twitter logo DISCUSS (12)
markdown guide

You'll want to look into provisioning your server with VirtualHost configurations in Apache.


Thanks Joshua for sharing your reply. So you're saying it's a setup on the server level and not the application level? Or perhaps a combination of both?


How you really want to handle it, is for each client, setup a different instance of the application. You can handle this in multiple ways. VirtualHosts are typically how we assign custom domains to their perspective instance.

1) Point the A Record of the domain to the IP of the server you intend to serve the application from.
2) Configure the server to accept the domain and serve your application.

I need to know more about the problem you are trying to solve before I can give you a solid solution for how you might host the application/server configuration. I could jump on a call and give you some direction once I hear more about what you are trying to accomplish.

I've add more details of what I'm trying to achieve on this comment.

Basically for folks to set up a profile, then at some point if they want, they can point a custom domain to said profile and it would show their profile on the application when folks hit their custom domain.

Like a blog platform would does this type of thing?

In that case, I would say that you can host within a single application. However, at the server level is where you would configure your VirtualHosts so that you can serve the application with different domains. At the application level, you will want a way to associate the custom domain with the client profile.

Yeah, I think the easiest comparison to the idea is a blog platform. Where a user can create content and "publish" it to the account on the platform I'm creating and then point their custom domain to it.

Thanks Joshua for the guidance! Think you've set me on a good path :)


Hey Michael,

If you choose the Heroku + Rails route, you could get a custom domain through following these steps:

If I'am understanding the question properly, I think this should be feasible and it should be a matter of setting up the DNS settings.

Hope I understood the question & this helps you :).

Best Regards!


Hey Edwin! Thanks for chiming in. I think an example might help clarify what I'm trying to do.

Let's say my app is located at

And let's say I have a user who's profile could be accessed at

Let's also say cooluser owns the domain and would like to point that domain to their profile on my application. So that when folks visit what gets shown is their profile on my application

Hope this clarifies things and wondering if your suggestion still applies to this :)


Ahh Michael.

Thanks for clarifying!

In that case, I don't believe the heroku guide will help you in your pursuit :(

However, it looks like this person on stack overflow is aiming to do something very alike -

^ there is an answer there which doesn't seem to have any response or thumbs up. Wondering if this will help.

Best wishes :)

Thanks Edwin for sending me your best wishes :) and lending me your Google-foo skills. Will definitely have a look as I continue my quest to achieve this solution.


You're looking to do essentially what GitHub Pages does with the custom domains.

Just a rough draft thought I'm having this morning but I would think you could have a database connecting the custom domains to profile IDs or whatever and then have a bash script that runs every 15 minutes that would then go create or destroy the (assuming Apache) VirtualHosts files pointing the domains to the profiles.

There's probably a more dynamic/optimized way to do that but it might work?

Classic DEV Post from Aug 8

DEV Went Open Source One Year Ago Today, And We Have So Much More Planned!

Michael Lee πŸ• profile image
Maker of things, giver of high-fives πŸ–

Better understand your code.