Hello!
I am working on new project and I have idea to provide free sub-domain for each registered user.
I want users to have their unique sub-domain, also they should be able to change A or NS for their sub-domain, if possible. I don’t need any sub-directories for them, just a domain, so they could use it for their own needs for free. Example: user.mydomain.com
So question, is it even possible here in DigitalOcean? And if it is, could you give me some tips or tutorials how to set it up? It can be done by DigitalOcean API? I am new to this. Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Yes, managing A records for subdomains be done using the API. I set up a similar setup for a project of mine not long ago. Here is what I did.
This will allow the user to change their A record to point to any IP address.
Currently our DNS system does not support subdomain NS records so using this method would not allow your users to set up NS records to delegate their subdomain to another DNS server. If that is a requirement you would have to look into setting up nameservers using BIND or another DNS server and write the code to modify those records.
Documentation on managing records within a domain via the API.
This comment has been deleted
I done it! Just what I wanted. Maybe this will be useful for someone, I was coding quickly, without any validations and so this more like an example, but it’s working, here is how I done it.
First of all, I use Laravel 5. But this will work for anyone who has Guzzle 4.0+ (doesn’t work on 6.0+).
In controller.
public function addDomain(){
$digitalOcean = new Client([
'base_url' => 'https://api.digitalocean.com/v2/',
'defaults' => [
'auth' => [
'YOUR_API_TOKEN_HERE',
':'
]
]
]);
$request = $digitalOcean->post('domains', [
'json' => [
'name' => 'example.domain.com',
'ip_address' => '123.123.123.123'
]
]);
$domain = $request->json();
dd($domain); // just to see result.
}
Digital Ocean is BEST!! <3
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.