Do I need to register a domain name for my subdomain? - web-hosting

I want to know if I need to register a separate domain name for my subdomain (example.mydomain.com).
Do I need to register another domain name to feed my subdomain?

Simple answer: No, you do not need to register a separate domain name for your subdomain.
Depending on your domain name provider, there will be options to create additional subdomains.

Related

Multi domain session cookie

I have 2 Asp.Net Core 2.2 applications and I want to share session between them. I've set up session in a SQL database and both connect ok. They are on different sub domains. I understand that I can set the Cookie.Domain the startup file, which would solve the problem at a basic level, so each application would create the cookie such that it can be accessed. e.g.
Domain 1. "www.website.com"
Domain 2. "dashboard.website.com"
At present these sites can't access each others session cookie.
If I set the domain cookie to ".website.com", both should be able to access this.
The problem is that we have multiple domains that use this website, so it could be:
www.domain1.com
dashboard.domain1.com
www.domain2.com
dashboard.domain2.com
www.domain3.com
dashboard.domain3.com
I need to be able to inject the current host name into the startup cookie domain, in order to have it dynamically set, depending on the domain of the active website.
Is this at all possible?
Just to clarify, www.domain1.com does not need to be able to access www.domain2.com.
Only the www. and dashboard. variations of each domain need to be able to connect to each other.
Thanks in advance,
David
To share sessions across applications, you need only follow the directions in the docs. It basically boils down to two things:
You need to persist the data protection keys to a common store that all the apps can access. A UNC path will do, or you can even use something like Azure Key Vault.
You need to set a common application name. Data protection values are segregated by application by default. Setting a custom name, which is then used across all the apps allows them to all access the same set of data.
As far as setting the cookie domain goes. There's no good way to do this by convention. The actual domain name is only available in the context of the request pipeline, which is not available to you in something like Startup (there's no request). Even if you could, it's not reliable anyways. In situations where you have a reverse proxy or, importantly , when hosting in containers, the domain will be localhost, since the actual domain isn't applied directly to the app.
Long and short, your best bet is to use configuration. You can, for example, have environment-specific JSON files like appsettings.Domain1.json, appsettings.Domain2.json, etc. Inside each, you can add a something like:
{
"CookieDomain": ".domain1.com"
}
Then, when you deploy, you set the environment to the appropriate domain, and that config file will be used. In Startup, you'd just do:
services.ConfigureApplicationCookie(o => {
o.Cookie.Domain = Configuration["CookieDomain"];
});

How to implement customer subdomain in Spring framework

In many of the SaaS web applications (ex, Atlassian JIRA), a user can have dedicated subdomain. For example, if my user name is helloworld, then after I log in to the web application, I am redirected to helloworld.atlassian.net
How to implement this in Spring Framework?
Do I have to have one application server instance running for each customer?
But this dosent seem to be the cheapest solution. Does Spring have such feature that I can create dynamic subdomain based on the username, and in the backend, only one instance of application server is running?
Create a custom filter which parses whole url and extracts subdomain, then check if the user is on proper domain with proper rights. Also worth mentioning Nginx should redirect "*.yourdomain.com" so all subdomains don't have to exist in Nginx, they could exist in database and each user has his unique or can be multiple sudomains attached, your custom filter does the checking on each request.

Scalable way to add third-level domains

Users of my app has an ability be get a third-level domain for them : my-domain.example.com. What is the scalable way to manage that on Fortrabbit?
I use CloudFlare for DNS management. I assume I can delegate domains via API with them. How can I automate it on a Fortrabbit side for that domain to resolve?
On fortrabbit, you probably don't have to use an API or something.
Just create a domain entry *.example.com that points to your document root. You will have to get the subdomain in your code.

Providing customers with domain aliasing

Currently I have an app which gives my users a custom subdomain.
neat.coolapp.com
However, I want my users to be able to CNAME their personal domain to that website.
ex. hey.neat.com -> neat.coolapp.com
Is this possible on heroku?
Thanks in advance for any insight.
You'll need to add whatever domain the customer wants to use to your application so the correct application on Heroku responds - you could do this either manually (via the heroku control panel) or use the heroku gem within your application to add the domain to your application via some kind of control panel if the customer is able to add their own domains.
In regards to cname's - I would suggest setting up something like proxy.yourwebsite.com as a CNAME to yourapp.heroku.com and then you get your customers to cname their domain to proxy.yourwebsite.com in their DNS config.
When you sign up for Heroku you will get a subdomain like
asdf.heroku.com
If you have a domain like mywebsite.com you can cname mywebsite.com to asdf.heroku.com and you will need to add mywebsite.com to Heroku's custom domain command.
From there I'm not sure, if you wanted to add mywebsite2.com without having to add it using the custom domain command you can try to cname it to mywebsite.com, if you have two domains you can try it out.

Custom Subdomains in Sinatra app

I want my Sinatra app to allow users to create an account and access it via a subdomain (i.e. your-account.myapp.com).
I found this to extract subdomains (http://gist.github.com/55784#file_subdomains.rb) but I'm having a hard time implementing it.
Any ideas?
I have an Account model (datamapper) with a field called account name, which should be the subdomain.
Thanks!
Sinara uses Rack to interact with the webserver.
You could put a Rack middleware before all requests to extract the subdomain, store it on a local variable and use it wherever you need load that user.
I've found 2 resources that could help you:
https://github.com/fnando/sinatra-subdomain
and
http://tannerburson.com/2009/01/extracting-subdomains-in-sinatra.html
Regards!

Resources