CNAME Domain Mapping/forwarding in a Saas Application - apache

I am trying to provide a feature for my users to map their custom domain [ which they will will purchase themselves ] and to their profile/page on my website say client.foo.com, using CNAME domain forwarding.
I have gone through various questions on StackOverflow regarding the same problem but all have focused on creating wildcard subdomains which I have already done and they function well.
Assumptions:
I am currently on a shared hosting, hence shared IP. [I can purchase a dedicated IP if that does the job efficiently.].
I am using apache server hence please suggest the solutions considering the same.
A better explanation of My issue - [Taken from other StackOverflow question, but solutions not as requested]:
I host at fooservice.com. For each user, they get their own subdomain bob.fooservice.com. I'm pretty sure I can get that part covered. Let's also assume that Bob wants the service to appear as a subdomain of his site awesomebob.com. He wants it to be foo.awesomebob.com. I know that what Bob has to do is add a CNAME record from foo.awesomebob.com -> bob.fooservice.com. My question is what do I have to do to make sure that valuable on my fooservice server.
Thank you for all your valuable suggestion well in advance.

Based on your explanation, you use wildcard subdomains, which all have the same IP I assume and you want to automate the process right?
So, as CNAME record is only pointing to the IP address, not redirecting, you need to create virtual host in the first order than other virtual host.
In this virtual host, create a script (index.php) to serve the correct subdomain's page from the requested custom domain.

Related

Google Domain forward to Digital Ocean linux server, running Apache2 subfolder, and display domain as root

I've been googling for a bit now, and I really cant seem to figure this out. I recently bought a domain name with google domains, that I wish to point to a sub domain on my web-server, (example) http://120.0.0.0/sub-folder/, while apearing as domain.com.
Right now I have mbektic.com forwarding to http://138.197.5.88/mbektic/ which kind of gets what I need done, but I wish for the URL to say mbektic.com, instead of the ip address of the server.
Now I've been looking around and I've found things mentioning things from creating records to .htaccess files, and honestly I'm completely lost.
If someone could point me to a straightforward guide or give me a list of steps to follow, I can do it myself, but currently I am just lost.
This really belongs on unix.se since it isn't programming...
That said, what you need to do is set up a DNS A record pointing your domain name to your IP address. Add a second one to handle www.example.com
Then, on the webserver, configure it to respond to that name and serve content out of the directory you specify (the apache webserver calls this the DocumentRoot - you may want to look up apache virtual hosts .... )

Point domain name to specific folder on server

I am currently working on a CMS type of site where users can create websites on my server.
I want to be able to create subdomains for the user's website for them to see the preview.
The next step would be for users to be able to point their domain name to my server, and when users go to the domain it would go to their own designated folder on my server.
How would I go about doing this automatically with php, I have been looking for solutions with no avail.
I currently have a Virtual Server with hostgator. Please advise, or point me in the right direction. Any solutions are welcome as well, I am pretty much stuck at this point.
Thank you very much.
EDIT
For example, if my domain is www.mydomain.com, when a user makes an account, the subdomain username.mydomain.com is created. Later down the line, if the user buys the domain name www.userdomain.com, I want to make it so that if www.userdomain.com is entered, it shows what is on www.mydomain.com/userdomain. The URL should still show www.userdomain.com
The answer is depends on which web server you are using ?(apache / nginx or any other)
You need to have separate directory for each sub domain you created
In your virtual host configuration you need to match the host name and get the subdomain as a parameter to set the root directory for your host name.
CNAME is also possible but if you can tell your web server there is a possibility for detailed answer.

How to Change Nameservers for Ghost Blog without Nuking Site

I've not gotten a definitive answer to this question from host or registrar, and hope I can explain it well enough here.
I have a domain registered with InternetBS.net and hosted through Site 5. It uses Site 5 nameservers.
I want to install a Ghost blog at blog.mysite.com. To do so, I need to add a CNAME record to the domain through InternetBS, redirecting blog.themeparkpress.com to my new Ghost blog.
So far, so good.
But when I do that, the nameservers will change automatically from those provided by Site 5 to those used by InternetBS.
I'm concerned that this change will make my site inaccessible (except for the lonely Ghost blog). Am I going about this in the right way?
Thanks!
You will need to use the name servers that belong to your domain registrar to make adjustments to the DNS information. You may want to check to see what, if any, additional information is in your domain records hosted by Site 5.

Apache Multiple Subdomain DNS Handling

I am currently building an application that I will host and will have multi-tenants (SaaS) called over the web, I would like them to be able to have subdomain.theircompany.com be able to point to subdomain.mycompany.com (or if they wish, point a full TLD to a subdomain with me).
The way I have been expecting this to work is to simply have a wildcard 'ServerAlias *.mycompany.com' in my Apache config pointing to my application, which then extracts the host being called...They then redirect via a CNAME entry on their host.
My question is, would this approach allow external subdomains to be pointed to a CNAME URL instead of IP? As this runs on one account on my system, am I able to install an SSL for a single wildcard if that customers wants to be running on SSL?
Any other suggestions/approaches would be greatly appreciated!
Thanks
A CNAME will work for the purposes of naming, but not for the purposes of a wildcard SSL cert.
Specifically, example.theircompany.com can have a CNAME record with a value of example.yourcompany.com. This will mean that example.theircompany.com will transparently resolve to your site. In other words, a browser still sees example.theircompany.com, not example.yourcompany.com.
As such, the SSL cert must be for the theircompany.com domain, not the yourcompany.com domain.

How to hide distributed servers under a single domain?

I currently host my company's website and blog on separate servers, reached by separate domain names - www.example.com and www.example.net. This is so I can give blog server access to our partners without compromising security on our main server. However, our SEO guy is now demanding that the blog be put on our main server, as www.example.com/blog.
I would like to maintain the current server separation rather than putting both on the same server. Is there any good way to keep them separated, but have them both under a single domain name? A subdomain would also be acceptable (blog.example.com).
My main website server is a Debian box running Apache 2, and I have full root access to it. The blog server is run by Hostgator, and I have limited access.
Edit: Thanks, all. In this particular situation I don't particularly want to transfer the blog again, and I don't have easy access to the DNS records, so i went with mod_proxy and it worked like a charm. I wish I could give you all "preferred answer" status, though, because all of your information was awesome.
A subdomain would be easy: just create an A record in DNS which maps blog.example.com to the IP address of the blog server, and have another A record in DNS which maps www.example.com to the main website server (this latter record probably already exists).
Would the SEO guy be happy with blog.example.com? It's not the same from an SEO perspective, but it might be good enough for him. I work at a company where SEO is at least 1/3 of what we do, and that's our setup: blog.example.com and www.example.com.
You could try to get fancy and proxy requests to /blog to the 2nd server, if you insist on keeping the blog off your box, but I think you can find a secure way to share space. Proxying like that could get annoying, and it basically doubles the latency to your blog.
Give the blog guys an account on your box; don't give them root/special privileges. If you can get away with it, don't even give them SSH access -- just give them a FTP login (make sure they can't access /var/www), and maybe a mysql account or something. (As you can see, this all depends on how much control/power the blog folks demand.)
Then, just make a symlink to the blog root, so they can write to a restricted area like /home/blog/www and still have it included in the website:
ln -s ~blog/www /var/www/blog
If a subdomain is for some reason not a possible way for you to go, you could use Apache's mod_proxy module to proxy requests to /blog to your second server.