Link to home
Create AccountLog in
Avatar of ckinikar
ckinikarFlag for United States of America

asked on

Bind9 and nginx configuration on Debian 7

Hi,

Problem: Only primary domain Domain1.com is working fine, Domain2.com is not accessing it's content whereas it is accessing content on Domain1.com. Both domains are resolving properly.

I am working on Debian 7 32bit VPS.
I have 1 IPv4 and 1IPv6 address.
I have to host 2 domains Domain1.com and Domain2.com
Domain1.com is primary domain and host-name of VPS is ns1.Domain1.com
Domain1.com has 1 subdomain and Domain1.com is configured for both http and https access.
Domain2.com is for normal http access and no subdomains.
I am migrated from CentOS 6.4 to Debian 7, where everything was working fine under Bind9 and apache2.2, server hostname and IP remained the same.
On Debian 7, I have installed nginx1.2.1 and Bind9
I have copied exactly same config for Bind9 from my CentOS config.
/etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
==================================
/etc/bind/named.conf.local

zone "domain1.com" {
        type master;
        file "domain1.com.db";
        notify no;
};

zone "domain2.com" {
        type master;
        file "domain2.com.db";
        notify no;
};

zone "10.10.10.10.in-addr.arpa" {
        type master;
        notify no;
        file "reverse/10.10.10.10";
=================================
/var/cache/bind/domain1.com.db

; BIND data file for domain1.com
;
$TTL 14400
@ IN SOA ns1.domain1.com. indo.domain1.com. (
201006601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL
;
domain1.com. IN NS ns1.domain1.com.
domain1.com. IN NS ns2.domain1.com.

domain1.com. IN A 10.10.10.10
domain1.com. IN AAAA 1111:222::333a:ab44

ns1 IN A 10.10.10.10
ns2 IN A 10.10.10.10

www IN CNAME domain1.com.
ftp IN CNAME domain1.com.


abc.domain1.com. IN CNAME example.com.

ns1 IN  AAAA  1111:222::333a:ab44
ns2 IN  AAAA  1111:222::333a:ab44
========================================
/var/cache/bind/domain2.com.db

; BIND data file for domain2.com
;
$TTL 14400
@ IN SOA ns1.domain2.com. indo.domain2.com. (
201006601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL
;
domain2.com. IN NS ns1.domain1.com.
domain2.com. IN NS ns2.domain1.com.

domain2.com. IN A 10.10.10.10


ns1 IN A 10.10.10.10
ns2 IN A 10.10.10.10
www IN CNAME domain2.com.
===========================================
/var/cache/bind/reverse/10.10.10.10

$TTL 14400
@ IN SOA domain1.com. indo.domain1.com. (
201006601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL

@                IN NS            ns1.domain1.com.
IN NS ns1.domain1.com.
IN NS ns2.domain1.com.

ns1	IN	A	10.10.10.10
ns2	IN	A	10.10.10.10

ns1 IN  AAAA  1111:222::333a:ab44
ns2 IN  AAAA  1111:222::333a:ab44

4 IN PTR domain1.com.

200       IN  PTR 	ns1.domain1.com.
201       IN  PTR 	ns2.domain1.com.

Open in new window

nginx configuration
/etc/nginx/nginx.conf
server {
listen   [::]:80;
        server_name domain1.com;
location / {
        root /site/domain1.com/;
        index index.php;
        autoindex on;
        }
        location ~ \.php$ {
        root /site/domain1.com/;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}
server {
listen   [::]:443;
        server_name domain1.com;
        server_name domain1.com;
        ssl on;
        ssl_session_cache    shared:SSL:10m;
        ssl_session_timeout  10m;
        ssl_certificate /etc/ssl/certs/domain1.crt;
        ssl_certificate_key /etc/ssl/private/domain1.key;
        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AES128-GCM-SHA256:ECDHE-RSA-AES128-HA256:RC4:HIGH:!MD5:!aNULL:!EDH;
        ssl_prefer_server_ciphers on;
location / {
        root /site/domain1.com/;
        index index.php;
        autoindex on;
        }
        location ~ \.php$ {
root /site/domain1.com/;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}
server {
listen   [::]:80;
        server_name abc.domain1.com;
location / {
        root /site/domain1.com/abc/;
        index index.php;
        autoindex on;
        }
        location ~ \.php$ {
        root /site/domain1.com/cdn/;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}
server {
listen   [::]:80;
        server_name domain2.com;
location / {
        root /site/domain2.com/;
        index index.php;
        autoindex on;
 }
        location ~ \.php$ {
        root /site/domain2.com/;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}
}

Open in new window


Please resolve my problem.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Mazdajai
Mazdajai
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of ckinikar

ASKER

When domain2.com is opened in the browser, it is opening index.php page from /site/domain1.com/ which is domain1's home page.
I cannot put trace here, because client don't allow me to do so.
Please suggest any possible errors or changes in the above config.
Thanks.
Excellent