Domain Mapping To Subdomain - linux

Im running SAAS where customer signs up and a script installation takes place in a subdomain, i.e., subdomain.mydomain.com and starts using the site. Now I want to allow my customers to map their FULL domain eg. www.customerdomain.com to subdomain.mydomain.com, something like bloggers.com or wordpress does. How I can do this. I am using Linux dedicated server. Help would be greatly appreciated. I dont want URL masking or redirection.

I'm currently developing a project and have recently faced the exact same issue. Here's two ways you can go about solving it:
Super-easy
A little more tricky, but not impossible
The first would be to allow domain mapping of subdomains (e.g. http://subdomain.example.com). This is dead simple for your users to setup. They would head over to their registrar and create a new CNAME record as follows:
(name) subdomain.example.com -> (record) subdomain.yoursite.com
Unlike changing A Records, this change only takes about 120 mins to fully propagate (compared with up to 72 hrs).
If your users pay for the privilege of using the domain mapping feature (i.e. it's not made available to users on a free plan), then you could could store each user's custom subdomain in your database, then check against this (in .php) when they try to access your website via their custom subdomain. If they're allowed, do nothing, otherwise redirect them to an alternate url.
So that's the easy one over and done with. Now for trickier option. If you have a dedicated IP address, or in your case a dedicated server, you can use the cPanel API to dynamically create A Records, this way users would be able to map their domain (rather just their subdomain) to your website. You would need to make the following A Record for your customer, together with getting them to update their domain's A Record with your dedicated IP address:
Your server:
(name) customersdomain.com -> (record) subdomain.yoursite.com
Customer's registrar:
www -> (record) [YOUR IP ADDRESS]
I'm not going to detail the API process for you, but you can read through the documentation here:
http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/ApiAuthentication
Anyways, I hope this helps and that you have fun building your website!
J

The (name) represents the custom domain belonging to your customer (e.g. customerdomain.com). The (record) would point to their subdomain on your SAAS site. So if I signed up to your website with a username of 'nike', you would use 'nike.yoursite.com'.
J

Install the wordpress domain mapping plugin, obviously your wordpress installation is setup for Wordpress MU.
Now the way I understand it you want to give your bloggers the opportunity to host their blog on their own personal domain while still hosting on your sever. Under "Domain Mapping" in "Settings" of "Network Administrator"(Super User).
There is Domain Options:
You want to check the User domain mapping page that's Option 3.
This will allow your blog users to specify the domain of their personal site. One thing to remind them is that their DNS records should point to your web server.

Related

What is the best way to move a large and complex site (which will need extensive testing) to a new server?

We need to move a large and complex site to a new server, and we need to ensure there is minimal downtime / disruption for our members.
This is what we have in mind:
Create a new domain (e.g. oursite.club) on the new server, for testing purposes. (We're planning on doing this because the temporary URL that works with some hosts / sites does not appear to work on ours)
Upload all existing code and import all databases to the new server.
Make any changes to allow for the new server path / domain name / different database names, where necessary.
Thoroughly test the .club site.
Add the current live domain (e.g. oursite.com) to the new server as an alias of the .club domain.
Once we're confident the new site works, change the DNS of the .com to point to the new server.
Also, add htaccess redirects on the old .com site to point to the same page on the .club domain, so that the site can still be accessed by those members for whom nameservers are not yet propagated.
After everything is working and all nameservers should have propagated, we want to make the .com the "real" domain and optionally retain the .club as an alias (i.e. swap the two domains on the new server).
This is what we have in mind:
Delete the add-on domain from the new server (i.e. the .club) and the alias domain (i.e. the .com) - but leave all the code / data where it is.
Re-add the .com, but point that at the server path where the .club code was uploaded.
Re-add the .club, but as an alias of the .com (or use URL forwarding at our domain registrar).
Make sure everything still works.
Update the htaccess redirects on the old server to send .com traffic to the .com domain on the new server, just in case there are any nameservers still pointing to the old server.
Since the nameservers for the two domains are already pointing to the new server, and that won't change, we thought this would offer the fastest way of swapping these two domains around.
We've done some testing with spare domains and a default WP blog, and this seems to work, but we wanted to call on your collective experience here to ask:
A. Will this work?
B. If not, what have we forgotten to take into account?
C. If so, good, but is there a better / easier way to accomplish this (especially the bit where we flip-flop the two domain names on the new server so that the current .com domain remains as the primary one to use)? For example, would it work if we add the .com to the new server (instead of creating a .club) and then edit our local hosts file during testing? Or can we use a VirtualHost directive to help with the domain swapping?
Although we've been building / running site for many years now, this is the first time we've had to move a membership site that is business-critical and where any excessive downtime / issues will cause us and/or our members real issues.
Many thanks!
I'm not sure if I'm missing something significant here (I don't entirely understand your need to flip flop the domains at the end), so I'll quite likely change this answer depending on comments etc (or delete it if I've completely missed a point!)
My approach to this would be
Set your DNS TTL for www.example.com to a very low number, 600 seconds perhaps. Don't plan the move until your current TTL expires (from the moment you make the change)
Create website on new server,configure the site under your example.club domain and example.com
Configure the hosts file on your testing machines with the IP Address of the server, and www.example.com This way your testing machines are going to actually test the full structure of example.com.
Test against example.club if you are concerned about broken links to the new domain, but since that is only temporary, it shouldn't really matter.
when it is tested and you are confident it is working, switch the DNS over.
Once you are comfortable that everything is working as expected reset your DNS TTL to a more sane figure.
As long as your database is in sync, there would be minimal (if any) downtime from this and at the end you can simply delete the example.club reference without any impact.
Depending on the value of the site, and the impact of potential downtime it might be worth putting a load balancer between both sites, and gradually increase the traffic that is sent to the new site so you can monitor progress. (you could use a load balancer from Azure which has no restrictions on being used against external sites)

Domain name point to subdomain of a entire different domain

I am completely confused the last few days with this and I still haven't found an outcome that's worked.
Basically I have a domain name without hosting at letshost.ie which is dublinplasterer.ie
I also Have one domain & hosting with godaddy for domain- shanafagan.com which is my own site for web/graphic design service.
I created a subdomain= dublinplasterer.shanafagan.com and uploaded the site files.
Basically I want for example when someone types in dublinplasterer.ie in the address bar if goes to dublinplasterer.shanafagan.com but doesn't show dublinplasterer.shanafagan.com url, stays as dublinplasterer.ie
Im not even sure if this can be done at this stage. head is melted
shanafagan.com and the subdomain dublinplasterer.shanafagan.com have the same ip so how will that work if changing dns?
Any help would be greatly appreciated , am so stuck at this stage.
If you wanted to do it this way you would need a web server for domain2.com
Search for ProxyPass.
The way you should do this is add a second domain on your web hosting (cpanel for example) and point the other domain to this web server.
If you are struggling I recommend using a solution like cPanel that is widely used and simplifies much of the process. It is common enough you can google most issues.
So normally you would have started by making an add-on domain (instead of a subdomain) which would also create it's own subdomain anyway. To do that, you go to your cPanel in GoDaddy and find add-on domain, then make it "dublinplasterer.ie" (Don't add www. to it. Even though this name is hosted elsewhere, we will later go to your DNS files at that hosting and point it to your GoDaddy's name servers and this add-on helps it direct to the right root folder) then choose your local root folder for that site (I think you can actually make this the same as your other subfolder already hosting your files and then it will just pull the same site) or you can pick a different subfolder and then make the add-on domain. This tells any request to this name server that if it is a request for "dublinplasterer.ie" it needs to send it to the subfolder you specified.
If you don't make the subfolder the same as the one you already made, you can either load the same content into your new subfolder or create a CNAME record telling this add-on to point to your subfolder instead but that is more complex so go with the other route.
Lastly, you need to go to your original hosting at letshost.ie and under your domain name find the DNS records tab. Change the name servers to match your GoDaddy ones and now (may take a day or two to show as DNS changes often take days and can't be seen immediately but you can try using a different device/computer/mobile that hasn't loaded it previously to see if it will refresh the correct dns) it should work. Even though it points to your main site name servers, the add-on domain you made receives it and directs it to the subfolder you specified on the add-on domain.
Hope that helps, let me know if it works for you.

Custom Domains for a Simple Web App

I've created a really simple databaseless php application that I want to offer as a hosted solution. I've enable wildcard subdomains so that users can sign up and create a subdomain (e.g. "user.myapp.com"). However, I would like to offer the ability for my users to use a custom domain as well if they prefer. I'm pretty sure this can be accomplished by asking the user to add an A Record to their custom domain pointing to my server's IP, but I'm not sure how to handle the domain on my end once they create an A Record pointing to my server's IP.
So, say a user signs up for my service under "user.myapp.com" and then they decide they want to use a custom domain "someuser.com" instead. My specific question is — once the user adds an A Record to their domain "someuser.com" pointing to my server's IP, how do I tell my server to point that domain to "user.myapp.com"? Or is there an easier way to do this?
You'd need to first setup your server to accept requests from someuser.com, which is entirely different than setting up a wildcard for your server alias (e.g. *.myapp.com). You can have a default vhost handle all the hostnames that no other vhost is setup to handle, but then you're still left with mapping someuser.com to user.myapp.com.
Depending on how you've setup your php application, the user's going to need to enter the custom domain they've registered that they had point to your app, then you'll need to know to do that mapping internally by checking the $_SERVER['HTTP_HOST'] server variable to see what host the request is for, and if it's for someuser.com, then map it to user.myapp.com.

Is there a way to find all existing subdomains of one main domain?

I work for Johns Hopkins University, and our web culture here has been an unruled wilderness for many years. We're trying to get a handle on the enormous number of registered subdomains across our part of the web-universe, and even our IT department is having some trouble tracking down the unabridged list.
Is there a tool or a script that would do this quickly and semi-easily? I'm a developer and would write something but I want to find out if this wheel has been created already.
Alternatively, is there a fancy way to google search, more than just *.jhu.edu or site: .jhu.edu, because those searches turn up tons of sites that use "jhu.edu" in the end of their urls (ex. www.keywordspy.com/organic/domain.aspx?q=cer.jhu.edu)
Thanks for your thoughts on this one!
The Google search site:*.jhu.edu seems to work well for me.
That said, you can also use Wolfram Alpha. Using this search, in the third box click "Subdomains" and then in the new subdomains section that is created click "More".
As #Mark B alluded to in his comment, the only way a domain name (sub or otherwise) has any real value is if a DNS service maps it to a server so that a browser can send it a request. The only way to track down all of the sub-domains is to track down their DNS entries. Thankfully, DNS servers are fairly easy to find, depending on the level of access you have to the network infrastructure and the authoritative DNS server for the parent domain.
If you are able to, you can pull DNS traffic from firewall logs in and around your network. That will let you find DNS servers that are being sent requests for your sub-domains.
Easier though would be to simply follow the DNS trail. The authoritative DNS server for your domain (jhu.edu) will have pointers to the other DNS servers that are authoritative for sub-domains (if your main one is not authoritative already).
If you have access to the domain registrar and have the proper authorization, you should be able to contact technical support and request the zone file or even export it yourself depending on the provider.

Custom Subdomain with CNAME Problem

I am having a bit of a struggle grasping how to use custom domains with my app. Its the common case of having an app that assigns users to subdomains, ex. user.theapp.com and they want to use a CNAME so m.theirsite.com resolves to the application. It seems that most services that do this require you to tell them what your custom domain is, and that just adding a CNAME record doesn't work. Steps:
User creates an account.
We tell them they can make a CNAME entry to yourstuff.theapp.com (which is the current location).
This is my confusion. After 1&2 my custom domain still isnt working.. so once the client makes that CNAME record and provides us with "m.theirsite.com", what special magic do we do with it to make those sites "the same"?
Thank you in advance.
Our solution was to use PHP/MySQL to solve this. As normal, you should have the external domain/subdomain CNAME'd to your app, however as you will see, the CNAME entry doesn't need to be to the exact subdomain on the app. Next, you will build an area into your database where a user can tell you what external site they have CNAME'd from. At this point, you will perform most of your authentication on the website based on the HTTP host, either grabbing the subdomain and using it as a client, or checking if the HTTP host is in your list of CNAME's and then referencing the client from there.
What the CNAME does is just point to a server location, so if you are using wildcards in your apache configuration, foo.myapp.com resolves to the same location as bar.myapp.com, but in the app can use the host to pull out the subdomain and find the client ("foo" and "bar"). When using a CNAME, like m.mywebsite.com --cnamed--> foo.myapp.com, the application no longer has that client information in the HTTP host, and as we mentioned, the apache wildcard setup (*.myapp.com) just tosses out the subdomain.. so because of this the client must tell us "I will be visiting from m.mywebsite.com, so make that a valid host name for my authentication as well."

Resources