By joeguilmette
What I’m shooting for:
What is happening:
ZONE file for domain1:
$TTL 1800
@ IN SOA NS1.DIGITALOCEAN.COM. hostmaster.domain1.com. (
1414393689 ; last update: 2014-10-27 07:08:09 UTC
3600 ; refresh
900 ; retry
1209600 ; expire
1800 ; ttl
)
IN NS NS1.DIGITALOCEAN.COM.
NS NS2.DIGITALOCEAN.COM.
NS NS3.DIGITALOCEAN.COM.
@ IN A drop.let.ip.address
ZONE file for domain2:
$TTL 1800
@ IN SOA NS1.DIGITALOCEAN.COM. hostmaster.domain2.com. (
1414403298 ; last update: 2014-10-27 09:48:18 UTC
3600 ; refresh
900 ; retry
1209600 ; expire
1800 ; ttl
)
IN NS NS1.DIGITALOCEAN.COM.
NS NS2.DIGITALOCEAN.COM.
NS NS3.DIGITALOCEAN.COM.
@ IN A drop.let.ip.address
*.sub1 IN A drop.let.ip.address
*.sub2 IN A drop.let.ip.address
Server blocks for domain1:
server {
server_name domain1.com;
rewrite ^(.*) http://www.domain1.com$1 permanent;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/user/www/domain1;
index index.php index.html index.htm;
server_name www.domain1.com;
include hhvm.conf;
}
Server blocks for domain2:
server {
server_name domain2.com;
rewrite ^(.*) http://www.domain2.com$1 permanent;
}
server {
listen 80;
listen [::]:80;
root /home/user/www/sub1;
index index.html index.htm index.php;
server_name sub1.domain2.com;
include hhvm.conf;
}
server {
listen 80;
listen [::]:80;
root /home/user/www/sub2;
index index.html index.htm index.php;
server_name sub2.domain2.com;
include hhvm.conf;
}
server {
listen 80;
listen [::]:80;
root /home/sub/www/domain2;
index index.html index.htm index.php;
server_name www.domain2.com;
include hhvm.conf;
}
I’ve been pulling my hair out all day, and I’m pretty sure the reason it’s so hard to google is because it’s a simple DNS issue and I have no idea what i’m doing with DNS.
Any help would be greatly appreciated.
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!
First you need to fix domain2. Delete the records of sub1 and sub2 and create CNAME records for them.
name: sub1, hostname: @
name: sub2, hostname: @
You probably want to handle www sub domains too so add a CNAME record the same way to domain1 and domain2, but this time use www as the name of the record.
If you want to handle www prefixes on your sub1 and sub2 sub domains then add another two CNAME records to domain2.
name: www.sub1, hostname: sub1
name: www.sub2, hostname: sub2
Your server blocks should look like this.
# www.domain1.com
server {
listen 80;
server_name www.domain1.com;
rewrite ^(.*) http://domain1.com$1 permanent;
}
# domain1.com
server {
listen 80 default_server;
server_name domain1.com;
root /home/user/www/domain1;
index index.php index.html index.htm;
include hhvm.conf;
}
# www.domain2.com
server {
listen 80;
server_name www.domain2.com;
rewrite ^(.*) http://domain2.com$1 permanent;
}
# domain2.com
server {
listen 80;
server_name domain2.com;
root /home/user/www/domain2;
index index.php index.html index.htm;
include hhvm.conf;
}
# www.sub1.domain2.com
server {
listen 80;
server_name www.sub1.domain2.com;
rewrite ^(.*) http://sub1.domain2.com$1 permanent;
}
# sub1.domain2.com
server {
listen 80;
server_name sub1.domain2.com;
root /home/user/www/sub1;
index index.php index.html index.htm;
include hhvm.conf;
}
# www.sub2.domain2.com
server {
listen 80;
server_name www.sub2.domain2.com;
rewrite ^(.*) http://sub2.domain2.com$1 permanent;
}
# sub2.domain2.com
server {
listen 80;
server_name sub2.domain2.com;
root /home/user/www/sub2;
index index.php index.html index.htm;
include hhvm.conf;
}
The default_server sets that block explicitly the default server. Droplet IP should be handled by that block. Make sure you don’t have a conflicting default server.
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.